From 45db69b97a101c4bbfa566a17a0e04da4fa68707 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Tue, 24 Jul 2018 18:48:39 +0900 Subject: [PATCH 01/56] gui_uspex: prepare unified gui interface I + some warning fixes. --- src/file_arc.c | 8 +- src/file_uspex.c | 4 +- src/gl_graph.c | 8 +- src/gl_main.c | 3 +- src/gui_defs.h | 206 +++++++++++++++++++++ src/gui_vasp.c | 461 ++++++++++++++++++++++++----------------------- src/project.c | 3 + 7 files changed, 454 insertions(+), 239 deletions(-) create mode 100644 src/gui_defs.h diff --git a/src/file_arc.c b/src/file_arc.c index 6fde7e2..60dee3a 100644 --- a/src/file_arc.c +++ b/src/file_arc.c @@ -205,9 +205,10 @@ return(FALSE); /* NB: assumes fp is at a line before !DATE line */ void read_arc_block(FILE *fp, struct model_pak *data) { -gint region, core_flag, end_count; +gint region=0; +gint core_flag, end_count; GSList *clist, *slist; -struct core_pak *core; +struct core_pak *core=NULL; struct shel_pak *shel; gchar *line; gdouble energy; @@ -390,7 +391,8 @@ gint read_arc(gchar *filename, struct model_pak *data) gint frame=0; gchar *line; FILE *fp; -long int fp_pos,old_fp_pos; +long int fp_pos; +long int old_fp_pos=0; /* checks */ g_return_val_if_fail(data != NULL, 1); diff --git a/src/file_uspex.c b/src/file_uspex.c index 09770af..762bbea 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -189,7 +189,7 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ /* specific */ gint idx=0; gchar *ptr; - gint max_struct; + gint max_struct=0; gint red_index; /*since energy is sometimes eV, and sometimes eV/atom ?*/ gboolean e_red=FALSE; @@ -303,7 +303,7 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ gint natoms; gint species_index; gdouble min_E; - gdouble min_F; + gdouble min_F=0.; gdouble max_E; gchar *atoms; uspex_calc_struct *uspex_calc; diff --git a/src/gl_graph.c b/src/gl_graph.c index bae3a90..4a93adc 100644 --- a/src/gl_graph.c +++ b/src/gl_graph.c @@ -578,8 +578,9 @@ gint size; gint shift; gint nkpoints; gdouble sz; -gdouble *xval; -gdouble xmin,xmax; +gdouble *xval=NULL; +gdouble xmin=0.; +gdouble xmax=0.; /* compute origin */ ox = canvas->x + 4*gl_fontsize; if (graph->ylabel) ox += 4*gl_fontsize; @@ -1278,7 +1279,8 @@ void graph_read(gchar *filename) { gint i, j, n, num_tokens; gchar *fullpath, *line, **buff; -gdouble xstart, xstop, x[GRAPH_SIZE_MAX], *y; +gdouble xstart=0.; +gdouble xstop, x[GRAPH_SIZE_MAX], *y; GArray *garray; gpointer graph; struct model_pak *model; diff --git a/src/gl_main.c b/src/gl_main.c index 3050357..12dfb55 100644 --- a/src/gl_main.c +++ b/src/gl_main.c @@ -1326,7 +1326,8 @@ g_assert(data != NULL); /* turn lighting off for wire frame drawing - looks esp ugly */ /* when hidden (stippled) lines and normal lines are overlayed */ -if (0.5*sysenv.render.wire_surface) +//if (0.5*sysenv.render.wire_surface) +if (((gint)0.5*sysenv.render.wire_surface)!=0) glDisable(GL_LIGHTING); glLineWidth(sysenv.render.frame_thickness); diff --git a/src/gui_defs.h b/src/gui_defs.h new file mode 100644 index 0000000..0aeea74 --- /dev/null +++ b/src/gui_defs.h @@ -0,0 +1,206 @@ +/* +Copyright (C) 2018 by Okadome Valencia + +hubert.valencia _at_ imass.nagoya-u.ac.jp + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +The GNU GPL can also be found at http://www.gnu.org +*/ + +/* graphic define interface */ +/**************************************************** + * By using compiler defines, this is aimed to be an + * easy to upgrade interface design: by just changing + * the content here will upgrade all files gui_* that + * use a specific GTK interface... --OVHPA + ****************************************************/ + +/* DEFINES: interface */ +#define GUI_SPACE 0 +/*****************/ +/* BOX INTERFACE */ +/*****************/ +/*Set a new horizontal box (hbox) in a vertical box (vbox).*/ +#define GUI_NEW_LINE(vbox,hbox) do{\ + hbox = gtk_hbox_new(FALSE, 0);\ + gtk_container_set_border_width(GTK_CONTAINER(hbox), GUI_SPACE);\ + gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);\ +}while(0) +/*Set a new label (label) with text ("text") in an horizontal box (hbox).*/ +#define GUI_NEW_LABEL(hbox,label,text) do{\ + label = gtk_label_new(text);\ + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);\ +}while(0) +/*Set a new text entry (entry) with initial value ("value") expanding (wilde=TRUE) or not (wilde=FALSE) in an horizontal box (hbox).*/ +#define GUI_TEXT_ENTRY(hbox,entry,value,wilde) do{\ + entry=gtk_entry_new();\ + if(value!=NULL) gtk_entry_set_text(GTK_ENTRY(entry),g_strdup_printf("%s",value));\ + gtk_box_pack_start(GTK_BOX(hbox), entry, wilde, wilde, 0);\ +}while(0) +/*Set a new entry (entry) with initial value (value) of format ("format") with a width of (size) characters, in an horizontal box (hbox).*/ +#define GUI_ENTRY(hbox,entry,value,format,size) do{\ + entry=gtk_entry_new();\ + gtk_entry_set_text(GTK_ENTRY(entry),g_strdup_printf(format,value));\ + gtk_entry_set_width_chars (GTK_ENTRY(entry),size);\ + gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);\ +}while(0) +/*Set a new separator (separator) in an horizontal box (hbox).*/ +#define GUI_NEW_SEPARATOR(hbox,separator) do{\ + separator=gtk_hseparator_new();\ + gtk_box_pack_start(GTK_BOX(hbox), separator, TRUE, FALSE, 0);\ +}while(0) +/*Set a new combo (combo), with an uneditable link to GLIST (list) which is FREED after link, with an initial value ("default_text"), and connected to function (function), in an horizontal box (hbox).*/ +/* THIS GTK COMBO USE IS DEPRECATED! */ +#define GUI_REG_COMBO(hbox,combo,list,default_text,function) do{\ + combo = gtk_combo_new();\ +_Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ + gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(combo)->entry), FALSE);\ + gtk_combo_set_popdown_strings(GTK_COMBO(combo), list);\ + g_list_free(list);\ + gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);\ + gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry),default_text);\ + g_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed",GTK_SIGNAL_FUNC(function),data);\ +}while(0) +/************************************************************************************/ +/* TABLE INTERFACE: */ +/* all of the *_TABLE() defines set a new table cell @l,r,t,b in table (table).*/ +/************************************************************************************/ +/*Create a new cell with: + * a boxed label (created with GUI_NEW_LABEL) with text ("caption"), + * an expanded text entry (entry, created with GUI_TEXT_ENTRY) with a default value ("value").*/ +#define GUI_TEXT_TABLE(table,entry,value,caption,l,r,t,b) do{\ + GtkWidget *_label;\ + GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ + GUI_NEW_LABEL(_hbox,_label,caption);\ + GUI_TEXT_ENTRY(_hbox,entry,value,TRUE);\ + gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ +}while(0) +/*Create a new cell with: + * a boxed label (created with GUI_NEW_LABEL) with text ("caption"), + * a boxed separator, + * a sized-8 boxed entry (entry, created with GUI_ENTRY) with an initial value (value) of format ("format").*/ +#define GUI_ENTRY_TABLE(table,entry,value,format,caption,l,r,t,b) do{\ + GtkWidget *_separator;\ + GtkWidget *_label;\ + GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ + GUI_NEW_LABEL(_hbox,_label,caption);\ + GUI_NEW_SEPARATOR(_hbox,_separator);\ + GUI_ENTRY(_hbox,entry,value,format,8);\ + gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ +}while(0) +/*Create a new cell with: + * a new check button (check) with an initial value (value) connected to function (function) with text ("caption").*/ +#define GUI_CHECK_TABLE(table,check,value,function,caption,l,r,t,b) do{\ + GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ + check = gui_direct_check(caption,&(value),function,NULL,_hbox);\ + gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ +}while(0) +/*Create a new cell with: + * a boxed label (created with GUI_NEW_LABEL) with text ("caption"), + * a boxed separator, + * a boxed combo (combo,created with GUI_REG_COMBO) linked to GLIST (list) which is FREED after GUI_REG_COMBO. + * */ +/* THIS GTK COMBO USE IS DEPRECATED! */ +#define GUI_COMBO_TABLE(table,combo,default_text,function,caption,l,r,t,b) do{\ + GtkWidget *_separator;\ + GtkWidget *_label;\ + GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ +_Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ + GUI_NEW_LABEL(_hbox,_label,caption);\ + GUI_NEW_SEPARATOR(_hbox,_separator);\ + GUI_REG_COMBO(hbox,combo,list,default_text,function);\ + gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ +}while(0) +/*Create a new cell with: + * a separator (not boxed!). + * a.k.a. an empty cell.*/ +#define GUI_SEPARATOR_TABLE(l,r,t,b) do{\ + GtkWidget *_separator = gtk_hseparator_new();\ + gtk_table_attach_defaults(GTK_TABLE(table),_separator,l,r,t,b);\ +}while(0) +/*Create a new cell with: + * a boxed label with text ("caption"), + * an extended boxed combobox which is set as uneditable.*/ +/* THIS IS THE PROPER (but not simplier) REPLACEMENT FOR GTK COMBO DEPRECATED INTERFACE! */ +#define GUI_COMBOBOX_TABLE(table,combobox,caption,l,r,t,b) do{\ + GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ + GtkWidget *_label = gtk_label_new(caption);\ + gtk_box_pack_start(GTK_BOX(_hbox),_label,FALSE,FALSE,0);\ + combobox=gtk_combo_box_text_new_with_entry();\ + gtk_entry_set_editable(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox))),FALSE);\ + gtk_box_pack_start(GTK_BOX(_hbox),combobox,TRUE,TRUE,0);\ + gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ +}while(0) +/*Add a new element with text ("text") in the combobox (combobox). + * This have to be called AFTER GUI_COMBOBOX.*/ +#define GUI_COMBOBOX_ADD(combobox,text) do{\ + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox),text);\ +}while(0) +/*Set a default value (default_value) of the combobox (combobox), and register the function (function) for a changed value in combobox. + * This have to be called AFTER GUI_COMBOBOX and preferentially after GUI_COMBOBOX_ADD added some elements to combobox. + * If GUI_COMBOBOX_ADD is called after, it may trigger the function (function) each time.*/ +#define GUI_COMBOBOX_SETUP(combobox,default_value,function) do{\ + gtk_combo_box_set_active(GTK_COMBO_BOX(combobox),default_value);\ + if((function)!=NULL) g_signal_connect(GTK_COMBO_BOX_TEXT(combobox),"changed",GTK_SIGNAL_FUNC(function),data);\ +}while(0) +/*Create a new cell with: + * a boxed spin button, which default value is 1 and interval is [1,100], and labeled with text ("caption"). + * Due to limitation of GTK, value has to be of double type and not integer (event though it make little sense).*/ +#define GUI_SPIN_TABLE(table,spin,value,function,caption,l,r,t,b) do{\ + GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ + spin = gui_direct_spin(caption,&(value),1.0,100.0,1.0,function,NULL,_hbox);\ + gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ +}while(0) +#define GUI_SPIN_RANGE(spin,min,max) do{\ + gtk_spin_button_set_range(GTK_SPIN_BUTTON(spin),min,max);\ +}while(0) +/*Create a new cell with: + * a button (not boxed!) of type (type) connected on click to function (function).*/ +#define GUI_BUTTON_TABLE(table,button,type,function,l,r,t,b) do{\ + button=gtk_button_new_from_stock(type);\ + gtk_table_attach_defaults(GTK_TABLE(table),button,l,r,t,b);\ + g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ +}while(0) +/*Create a new cell with: + * a boxed button (button_1) of type APPLY connected on click to function (function_1), + * a boxed button (button_2) of type DELETE connected on click to function (function_2).*/ +#define GUI_2BUTTONS_TABLE(table,button_1,button_2,function_1,function_2,l,r,t,b) do{\ + GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ + button_1 = gui_stock_button(GTK_STOCK_APPLY,function_1,NULL,_hbox);\ + button_2 = gui_stock_button(GTK_STOCK_DELETE,function_2,NULL,_hbox);\ + gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ +}while(0) +/*left aligned labels*/ +/*Create a new cell with: + * a boxed label with text ("caption"), + * a separator. + * a.k.a. a left aligned label.*/ +#define GUI_LABEL_TABLE(table,caption,l,r,t,b) do{\ + GtkWidget *_separator;\ + GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ + GtkWidget *_label = gtk_label_new(caption);\ + gtk_box_pack_start(GTK_BOX(_hbox),_label,FALSE,FALSE,0);\ + GUI_NEW_SEPARATOR(_hbox,_separator);\ + gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ +}while(0) +/************************/ +/* GENERAL GTK COMMANDS */ +/************************/ +/*create a tooltip with text ("text") for the widget (widget).*/ +#define GUI_TOOLTIP(widget,text) gtk_widget_set_tooltip_text(widget,text) +/*set sensitivity of a widget*/ +#define GUI_LOCK(widget) gtk_widget_set_sensitive(widget,FALSE) +#define GUI_UNLOCK(widget) gtk_widget_set_sensitive(widget,TRUE) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index bb07a82..e106e77 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -48,6 +48,7 @@ The GNU GPL can also be found at http://www.gnu.org #include "dialog.h" #include "gui_shorts.h" #include "file_vasp.h" +#include "gui_defs.h" #include "gui_vasp.h" extern struct sysenv_pak sysenv; @@ -2729,16 +2730,16 @@ void gui_vasp_dialog(void){ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, _SPACE); label = gtk_label_new(g_strdup_printf("MODEL NAME")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - VASP_TEXT_ENTRY(vasp_gui.name,g_strdup_printf("%s",data->basename),TRUE); -VASP_TOOLTIP(vasp_gui.name,"The model name will be used in VASP files\nas well as GDIS display."); + GUI_TEXT_ENTRY(hbox,vasp_gui.name,data->basename,TRUE); +GUI_TOOLTIP(vasp_gui.name,"The model name will be used in VASP files\nas well as GDIS display."); /* --- CONNECTED XML */ hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, _SPACE); label = gtk_label_new(g_strdup_printf("CONNECTED XML")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); - VASP_TEXT_ENTRY(vasp_gui.file_entry,data->filename,TRUE); + GUI_TEXT_ENTRY(hbox,vasp_gui.file_entry,data->filename,TRUE); if(data->id!=VASP) gtk_entry_set_text(GTK_ENTRY(vasp_gui.file_entry),""); -VASP_TOOLTIP(vasp_gui.file_entry,"Use the result of a calculation (vasprun.xml)\nas a model to fill up settings of the current one.\nNOTE: important settings (such as NELM) will be wrong\nand all settings should be checked again. Carefully."); +GUI_TOOLTIP(vasp_gui.file_entry,"Use the result of a calculation (vasprun.xml)\nas a model to fill up settings of the current one.\nNOTE: important settings (such as NELM) will be wrong\nand all settings should be checked again. Carefully."); button=gtk_button_new_from_stock(GTK_STOCK_OPEN); gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(load_vasprun_dialog),NULL); @@ -2765,54 +2766,54 @@ VASP_TOOLTIP(vasp_gui.file_entry,"Use the result of a calculation (vasprun.xml)\ table = gtk_table_new(5, 4, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.simple_calcul,"CALCUL:",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.simple_calcul,"Energy (single point)"); - VASP_COMBOBOX_ADD(vasp_gui.simple_calcul,"DOS/BANDS (single point)"); - VASP_COMBOBOX_ADD(vasp_gui.simple_calcul,"Lattice Dynamics (opt.)"); - VASP_COMBOBOX_ADD(vasp_gui.simple_calcul,"Geometry (opt.)"); - VASP_COMBOBOX_ADD(vasp_gui.simple_calcul,"Molecular Dynamics (opt.)"); -VASP_TOOLTIP(vasp_gui.simple_calcul,"What is the intended calculation type?"); - VASP_CHECK_TABLE(button,vasp_gui.simple_rgeom,NULL,"ROUGH GEOM.",2,3,0,1);/*not calling anything*/ -VASP_TOOLTIP(button,"Is the current geometry:\nFAR from groundstate geometry\nor NOT-SO-FAR from it?"); - VASP_SPIN_TABLE(vasp_gui.simple_dim,vasp_gui.dimension,NULL,"DIM:",3,4,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.simple_dim,"What is the dimension of system?\nThe DIM (0D, 1D, 2D, or 3D) will be used\nto determine some parameters in INCAR and KPOINTS\nNO CHANGE will be made to the current geometry!"); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.simple_dim),0.0,3.0);/*0D~3D*/ + GUI_COMBOBOX_TABLE(table,vasp_gui.simple_calcul,"CALCUL:",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.simple_calcul,"Energy (single point)"); + GUI_COMBOBOX_ADD(vasp_gui.simple_calcul,"DOS/BANDS (single point)"); + GUI_COMBOBOX_ADD(vasp_gui.simple_calcul,"Lattice Dynamics (opt.)"); + GUI_COMBOBOX_ADD(vasp_gui.simple_calcul,"Geometry (opt.)"); + GUI_COMBOBOX_ADD(vasp_gui.simple_calcul,"Molecular Dynamics (opt.)"); +GUI_TOOLTIP(vasp_gui.simple_calcul,"What is the intended calculation type?"); + GUI_CHECK_TABLE(table,button,vasp_gui.simple_rgeom,NULL,"ROUGH GEOM.",2,3,0,1);/*not calling anything*/ +GUI_TOOLTIP(button,"Is the current geometry:\nFAR from groundstate geometry\nor NOT-SO-FAR from it?"); + GUI_SPIN_TABLE(table,vasp_gui.simple_dim,vasp_gui.dimension,NULL,"DIM:",3,4,0,1);/*not calling anything*/ +GUI_TOOLTIP(vasp_gui.simple_dim,"What is the dimension of system?\nThe DIM (0D, 1D, 2D, or 3D) will be used\nto determine some parameters in INCAR and KPOINTS\nNO CHANGE will be made to the current geometry!"); + GUI_SPIN_RANGE(vasp_gui.simple_dim,0.0,3.0);/*0D~3D*/ /* 2nd line */ - VASP_COMBOBOX_TABLE(vasp_gui.simple_system,"SYSTEM:",0,1,1,2); - VASP_COMBOBOX_ADD(vasp_gui.simple_system,"Metal"); - VASP_COMBOBOX_ADD(vasp_gui.simple_system,"Semi-conducting"); - VASP_COMBOBOX_ADD(vasp_gui.simple_system,"Insulator"); - VASP_COMBOBOX_ADD(vasp_gui.simple_system,"Unknown"); -VASP_TOOLTIP(vasp_gui.simple_system,"What is the electronic properties of the intended material?"); - VASP_TEXT_TABLE(vasp_gui.simple_poscar,vasp_gui.calc.species_symbols,"POSCAR:",1,4,1,2); -VASP_TOOLTIP(vasp_gui.simple_poscar,"Atomic symbols of the species\ndetected from the model geometry."); - gtk_widget_set_sensitive(vasp_gui.simple_poscar,FALSE); + GUI_COMBOBOX_TABLE(table,vasp_gui.simple_system,"SYSTEM:",0,1,1,2); + GUI_COMBOBOX_ADD(vasp_gui.simple_system,"Metal"); + GUI_COMBOBOX_ADD(vasp_gui.simple_system,"Semi-conducting"); + GUI_COMBOBOX_ADD(vasp_gui.simple_system,"Insulator"); + GUI_COMBOBOX_ADD(vasp_gui.simple_system,"Unknown"); +GUI_TOOLTIP(vasp_gui.simple_system,"What is the electronic properties of the intended material?"); + GUI_TEXT_TABLE(table,vasp_gui.simple_poscar,vasp_gui.calc.species_symbols,"POSCAR:",1,4,1,2); +GUI_TOOLTIP(vasp_gui.simple_poscar,"Atomic symbols of the species\ndetected from the model geometry."); + GUI_LOCK(vasp_gui.simple_poscar); /* 3rd line */ - VASP_COMBOBOX_TABLE(vasp_gui.simple_kgrid,"KPT GRID:",0,1,2,3); - VASP_COMBOBOX_ADD(vasp_gui.simple_kgrid,"COARSE"); - VASP_COMBOBOX_ADD(vasp_gui.simple_kgrid,"MEDIUM"); - VASP_COMBOBOX_ADD(vasp_gui.simple_kgrid,"FINE"); - VASP_COMBOBOX_ADD(vasp_gui.simple_kgrid,"ULTRA-FINE"); -VASP_TOOLTIP(vasp_gui.simple_kgrid,"What is the intended k-point grid density?"); - VASP_TEXT_TABLE(vasp_gui.simple_species,vasp_gui.calc.potcar_species,"POTCAR:",1,4,2,3); -VASP_TOOLTIP(vasp_gui.simple_species,"From POTCAR file, the following species are detected.\nThis should match the POSCAR definition above."); - gtk_widget_set_sensitive(vasp_gui.simple_species,FALSE); + GUI_COMBOBOX_TABLE(table,vasp_gui.simple_kgrid,"KPT GRID:",0,1,2,3); + GUI_COMBOBOX_ADD(vasp_gui.simple_kgrid,"COARSE"); + GUI_COMBOBOX_ADD(vasp_gui.simple_kgrid,"MEDIUM"); + GUI_COMBOBOX_ADD(vasp_gui.simple_kgrid,"FINE"); + GUI_COMBOBOX_ADD(vasp_gui.simple_kgrid,"ULTRA-FINE"); +GUI_TOOLTIP(vasp_gui.simple_kgrid,"What is the intended k-point grid density?"); + GUI_TEXT_TABLE(table,vasp_gui.simple_species,vasp_gui.calc.potcar_species,"POTCAR:",1,4,2,3); +GUI_TOOLTIP(vasp_gui.simple_species,"From POTCAR file, the following species are detected.\nThis should match the POSCAR definition above."); + GUI_LOCK(vasp_gui.simple_species); /* 4th line */ - VASP_TEXT_TABLE(vasp_gui.simple_potcar,vasp_gui.calc.potcar_file,"POTCAR FILE:",0,3,3,4); -VASP_TOOLTIP(vasp_gui.simple_potcar,"Where is the POTCAR file for this calculation?"); - VASP_BUTTON_TABLE(vasp_gui.simple_potcar_button,GTK_STOCK_OPEN,load_potcar_file_dialog,3,4,3,4); + GUI_TEXT_TABLE(table,vasp_gui.simple_potcar,vasp_gui.calc.potcar_file,"POTCAR FILE:",0,3,3,4); +GUI_TOOLTIP(vasp_gui.simple_potcar,"Where is the POTCAR file for this calculation?"); + GUI_BUTTON_TABLE(table,vasp_gui.simple_potcar_button,GTK_STOCK_OPEN,load_potcar_file_dialog,3,4,3,4); /* 5th line */ - VASP_LABEL_TABLE("EXEC:",0,1,4,5); - VASP_SPIN_TABLE(vasp_gui.simple_np,vasp_gui.calc.job_nproc,parallel_eq,"NP=",1,2,4,5); -VASP_TOOLTIP(vasp_gui.simple_np,"How many CPU(s) should be used for calculation?"); - VASP_SPIN_TABLE(vasp_gui.simple_ncore,vasp_gui.calc.ncore,parallel_eq,"NCORE=",2,3,4,5); -VASP_TOOLTIP(vasp_gui.simple_ncore,"How many CPU(s) should work on one band?"); - VASP_SPIN_TABLE(vasp_gui.simple_kpar,vasp_gui.calc.kpar,parallel_eq,"KPAR=",3,4,4,5); -VASP_TOOLTIP(vasp_gui.simple_kpar,"How many k-points should be worked on at a time?\nNote: each k-point is worked on by NCORE CPU(s)."); + GUI_LABEL_TABLE(table,"EXEC:",0,1,4,5); + GUI_SPIN_TABLE(table,vasp_gui.simple_np,vasp_gui.calc.job_nproc,parallel_eq,"NP=",1,2,4,5); +GUI_TOOLTIP(vasp_gui.simple_np,"How many CPU(s) should be used for calculation?"); + GUI_SPIN_TABLE(table,vasp_gui.simple_ncore,vasp_gui.calc.ncore,parallel_eq,"NCORE=",2,3,4,5); +GUI_TOOLTIP(vasp_gui.simple_ncore,"How many CPU(s) should work on one band?"); + GUI_SPIN_TABLE(table,vasp_gui.simple_kpar,vasp_gui.calc.kpar,parallel_eq,"KPAR=",3,4,4,5); +GUI_TOOLTIP(vasp_gui.simple_kpar,"How many k-points should be worked on at a time?\nNote: each k-point is worked on by NCORE CPU(s)."); /* initialize */ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.simple_calcul),0);/*not calling anything*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.simple_system),0);/*not calling anything*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.simple_kgrid),0);/*not calling anything*/ + GUI_COMBOBOX_SETUP(vasp_gui.simple_calcul,0,NULL);/*not calling anything*/ + GUI_COMBOBOX_SETUP(vasp_gui.simple_system,0,NULL);/*not calling anything*/ + GUI_COMBOBOX_SETUP(vasp_gui.simple_kgrid,0,NULL);/*not calling anything*/ /* --- end frame */ /* --- DISCLAMER */ frame = gtk_frame_new("DISCLAMER"); @@ -2829,8 +2830,8 @@ VASP_TOOLTIP(vasp_gui.simple_kpar,"How many k-points should be worked on at a ti /* 3th line */ label = gtk_label_new("GENERATE ==>"); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,3,4); - VASP_BUTTON_TABLE(vasp_gui.simple_apply,GTK_STOCK_APPLY,vasp_apply_simple,1,2,3,4); -VASP_TOOLTIP(vasp_gui.simple_apply,"Use this to obtain a preset of setting.\nIf calculation is already set using this will\noverwrite settings resulting in an unpredictable state."); + GUI_BUTTON_TABLE(table,vasp_gui.simple_apply,GTK_STOCK_APPLY,vasp_apply_simple,1,2,3,4); +GUI_TOOLTIP(vasp_gui.simple_apply,"Use this to obtain a preset of setting.\nIf calculation is already set using this will\noverwrite settings resulting in an unpredictable state."); label = gtk_label_new("<== (and check...)"); gtk_table_attach_defaults(GTK_TABLE(table),label,2,3,3,4); /* --- end frame */ @@ -2874,15 +2875,15 @@ VASP_TOOLTIP(vasp_gui.simple_apply,"Use this to obtain a preset of setting.\nIf VASP_COMBOBOX_ADD(vasp_gui.prec,"High"); VASP_COMBOBOX_ADD(vasp_gui.prec,"Medium"); VASP_COMBOBOX_ADD(vasp_gui.prec,"Low"); -VASP_TOOLTIP(vasp_gui.prec,"PREC: Ch. 6.11 DEFAULT: Normal\nSets numerical accuracy by changing\nENCUT, NG{X,Y,Z}, NG{X,Y,Z}F, and ROPT.\n(can be override manually)"); +GUI_TOOLTIP(vasp_gui.prec,"PREC: Ch. 6.11 DEFAULT: Normal\nSets numerical accuracy by changing\nENCUT, NG{X,Y,Z}, NG{X,Y,Z}F, and ROPT.\n(can be override manually)"); VASP_CHECK_TABLE(button,vasp_gui.calc.use_prec,prec_toggle,"USE PREC",1,2,0,1); -VASP_TOOLTIP(button,"Let PREC decides on ENCUT, NG{X,Y,Z}, NG{X,Y,Z}F, and ROPT."); +GUI_TOOLTIP(button,"Let PREC decides on ENCUT, NG{X,Y,Z}, NG{X,Y,Z}F, and ROPT."); VASP_ENTRY_TABLE(vasp_gui.encut,vasp_gui.calc.encut,"%.2lf","ENCUT=",2,3,0,1); -VASP_TOOLTIP(vasp_gui.encut,"ENCUT: Ch. 6.9 DEFAULT: MAX(ENMAX)\nPlane-wave basis cutoff energy (eV).\nDefault MAX(ENMAX) is taken from POTCAR file."); +GUI_TOOLTIP(vasp_gui.encut,"ENCUT: Ch. 6.9 DEFAULT: MAX(ENMAX)\nPlane-wave basis cutoff energy (eV).\nDefault MAX(ENMAX) is taken from POTCAR file."); VASP_ENTRY_TABLE(vasp_gui.enaug,vasp_gui.calc.enaug,"%.2lf","ENAUG=",3,4,0,1); -VASP_TOOLTIP(vasp_gui.enaug,"ENAUG: Ch. 6.10 DEFAULT: EAUG\nKinetic cutoff for augmentation charges.\nDefault EAUG is taken from POTCAR file."); +GUI_TOOLTIP(vasp_gui.enaug,"ENAUG: Ch. 6.10 DEFAULT: EAUG\nKinetic cutoff for augmentation charges.\nDefault EAUG is taken from POTCAR file."); VASP_ENTRY_TABLE(vasp_gui.ediff,vasp_gui.calc.ediff,"%.2lE","EDIFF=",4,5,0,1); -VASP_TOOLTIP(vasp_gui.ediff,"EDIFF: Ch. 6.18 DEFAULT: 10^{-4}\nSet the criterion (eV) for electronic convergence."); +GUI_TOOLTIP(vasp_gui.ediff,"EDIFF: Ch. 6.18 DEFAULT: 10^{-4}\nSet the criterion (eV) for electronic convergence."); /* 2nd line */ VASP_COMBOBOX_TABLE(vasp_gui.algo,"ALGO=",0,1,1,2); VASP_COMBOBOX_ADD(vasp_gui.algo,"NORMAL"); @@ -2898,15 +2899,15 @@ VASP_TOOLTIP(vasp_gui.ediff,"EDIFF: Ch. 6.18 DEFAULT: 10^{-4}\nSet the criterion VASP_COMBOBOX_ADD(vasp_gui.algo,"NOTHING"); VASP_COMBOBOX_ADD(vasp_gui.algo,"EXACT"); VASP_COMBOBOX_ADD(vasp_gui.algo,"DIAG"); -VASP_TOOLTIP(vasp_gui.algo,"ALGO: Ch. 6.46 DEFAULT: Normal\nSelect the electronic minimization algorithm.\nIt is overrided by IALGO when specified."); +GUI_TOOLTIP(vasp_gui.algo,"ALGO: Ch. 6.46 DEFAULT: Normal\nSelect the electronic minimization algorithm.\nIt is overrided by IALGO when specified."); VASP_CHECK_TABLE(button,vasp_gui.calc.ldiag,NULL,"LDIAG",1,2,1,2);/*not calling anything*/ -VASP_TOOLTIP(button,"LDIAG: Ch. 6.47 DEFAULT: TRUE\nSwitch on the sub-space rotation."); +GUI_TOOLTIP(button,"LDIAG: Ch. 6.47 DEFAULT: TRUE\nSwitch on the sub-space rotation."); VASP_ENTRY_TABLE(vasp_gui.nsim,vasp_gui.calc.nsim,"%i","NSIM=",2,3,1,2); -VASP_TOOLTIP(vasp_gui.nsim,"NSIM: Ch. 6.48 DEFAULT: 4\nNumber of bands optimized at a time\nin blocked minimization algorithm."); +GUI_TOOLTIP(vasp_gui.nsim,"NSIM: Ch. 6.48 DEFAULT: 4\nNumber of bands optimized at a time\nin blocked minimization algorithm."); VASP_ENTRY_TABLE(vasp_gui.vtime,vasp_gui.calc.vtime,"%.4lf","TIME=",3,4,1,2); -VASP_TOOLTIP(vasp_gui.vtime,"TIME: Ch. 6.51 DEFAULT: 0.4\nSelect the trial time or value step\nfor minimization algorithm IALGO=5X."); +GUI_TOOLTIP(vasp_gui.vtime,"TIME: Ch. 6.51 DEFAULT: 0.4\nSelect the trial time or value step\nfor minimization algorithm IALGO=5X."); VASP_ENTRY_TABLE(vasp_gui.iwavpr,vasp_gui.calc.iwavpr,"%i","IWAVPR=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.iwavpr,"IWAVPR: Ch. 6.26 DEFAULT: 2(IBRION=0-2)\nDetermine how charge density/orbitals are predicted\nfrom one ionic configuration to the next.\nDefault is 0 if IBRION is different from 0-2."); +GUI_TOOLTIP(vasp_gui.iwavpr,"IWAVPR: Ch. 6.26 DEFAULT: 2(IBRION=0-2)\nDetermine how charge density/orbitals are predicted\nfrom one ionic configuration to the next.\nDefault is 0 if IBRION is different from 0-2."); /* 3rd line */ VASP_COMBOBOX_TABLE(vasp_gui.ialgo,"IALGO=",0,1,2,3); VASP_COMBOBOX_ADD(vasp_gui.ialgo,"2:FIXED ORB/1E"); @@ -2924,22 +2925,22 @@ VASP_TOOLTIP(vasp_gui.iwavpr,"IWAVPR: Ch. 6.26 DEFAULT: 2(IBRION=0-2)\nDetermine VASP_COMBOBOX_ADD(vasp_gui.ialgo,"54:VAR DAMPED QUENCH MD"); VASP_COMBOBOX_ADD(vasp_gui.ialgo,"58:VAR PRECOND. CG"); VASP_COMBOBOX_ADD(vasp_gui.ialgo,"90:EXACT"); -VASP_TOOLTIP(vasp_gui.ialgo,"IALGO: Ch. 6.47 DEFAULT: 38\nSets the minimization algorithm number.\nIt is advised to use ALGO instead of IALGO\ndue to instabilities in extra IALGO algorithms."); +GUI_TOOLTIP(vasp_gui.ialgo,"IALGO: Ch. 6.47 DEFAULT: 38\nSets the minimization algorithm number.\nIt is advised to use ALGO instead of IALGO\ndue to instabilities in extra IALGO algorithms."); VASP_CHECK_TABLE(button,vasp_gui.calc.auto_elec,elec_toggle,"AUTO",1,2,2,3); -VASP_TOOLTIP(button,"Automatically sets NSIM, TIME, IWAVPR, NBANDS, and NELECT"); +GUI_TOOLTIP(button,"Automatically sets NSIM, TIME, IWAVPR, NBANDS, and NELECT"); VASP_ENTRY_TABLE(vasp_gui.nbands,vasp_gui.calc.nbands,"%i","NBANDS=",2,3,2,3); -VASP_TOOLTIP(vasp_gui.nbands,"NBANDS: Ch. 6.5 DEFAULT: NELEC/2+NIONS/2\nNumber of bands in the calculation.\nDefault for spin-polarized calcualtions is 0.6*NELECT+NMAG"); +GUI_TOOLTIP(vasp_gui.nbands,"NBANDS: Ch. 6.5 DEFAULT: NELEC/2+NIONS/2\nNumber of bands in the calculation.\nDefault for spin-polarized calcualtions is 0.6*NELECT+NMAG"); VASP_ENTRY_TABLE(vasp_gui.nelect,vasp_gui.calc.nelect,"%.2lf","NELECT=",3,4,2,3); -VASP_TOOLTIP(vasp_gui.nelect,"NELECT: Ch. 6.35 DEFAULT: Ne valence\nSets the number of electrons\nCan be use add an extra charge background\nas an homogeneous background-charge."); +GUI_TOOLTIP(vasp_gui.nelect,"NELECT: Ch. 6.35 DEFAULT: Ne valence\nSets the number of electrons\nCan be use add an extra charge background\nas an homogeneous background-charge."); /*empty: col4*/ /* 4th line */ /*empty: col0*/ VASP_CHECK_TABLE(button,vasp_gui.calc.iniwav,NULL,"INIWAV",1,2,3,4);/*not calling anything*/ -VASP_TOOLTIP(button,"INIWAV: Ch. 6.16 DEFAULT: 1\nDetermine how initial wavefunctions are filled\nThe only option is the default random filling.\nOther option (INIWAV=0) is usually not available."); +GUI_TOOLTIP(button,"INIWAV: Ch. 6.16 DEFAULT: 1\nDetermine how initial wavefunctions are filled\nThe only option is the default random filling.\nOther option (INIWAV=0) is usually not available."); VASP_ENTRY_TABLE(vasp_gui.istart,vasp_gui.calc.istart,"%i","ISTART=",2,3,3,4); -VASP_TOOLTIP(vasp_gui.istart,"ISTART: Ch. 6.14 DEFAULT 1\nDetermine whether WAVECAR should be read.\nDefault is 0 when no WAVECAR file is found."); +GUI_TOOLTIP(vasp_gui.istart,"ISTART: Ch. 6.14 DEFAULT 1\nDetermine whether WAVECAR should be read.\nDefault is 0 when no WAVECAR file is found."); VASP_ENTRY_TABLE(vasp_gui.icharg,vasp_gui.calc.icharg,"%i","ICHARG=",3,4,3,4); -VASP_TOOLTIP(vasp_gui.icharg,"ICHARG: Ch. 6.15 DEFAULT 2\nDetermine how the initial charge density is calculated\nDefault is 0 if ISTART is not 0."); +GUI_TOOLTIP(vasp_gui.icharg,"ICHARG: Ch. 6.15 DEFAULT 2\nDetermine how the initial charge density is calculated\nDefault is 0 if ISTART is not 0."); /*empty: col4*/ /* initialize */ VASP_COMBOBOX_SETUP(vasp_gui.prec,0,vasp_prec_selected); @@ -2961,41 +2962,41 @@ VASP_TOOLTIP(vasp_gui.icharg,"ICHARG: Ch. 6.15 DEFAULT 2\nDetermine how the init VASP_COMBOBOX_ADD(vasp_gui.mixer,"1:KERKER"); VASP_COMBOBOX_ADD(vasp_gui.mixer,"2:TCHEBYCHEV"); VASP_COMBOBOX_ADD(vasp_gui.mixer,"4:BROYDEN"); -VASP_TOOLTIP(vasp_gui.mixer,"IMIX: Ch. 6.49 DEFAULT: 4\nDetermine the type of mixing."); +GUI_TOOLTIP(vasp_gui.mixer,"IMIX: Ch. 6.49 DEFAULT: 4\nDetermine the type of mixing."); VASP_CHECK_TABLE(button,vasp_gui.calc.auto_mixer,mixer_toggle,"AUTO MIXER",1,2,0,1); -VASP_TOOLTIP(button,"Use automatic mixing settings."); +GUI_TOOLTIP(button,"Use automatic mixing settings."); VASP_ENTRY_TABLE(vasp_gui.nelm,vasp_gui.calc.nelm,"%i","NELM=",2,3,0,1); -VASP_TOOLTIP(vasp_gui.nelm,"NELM: Ch. 6.17 DEFAULT: 60\nMaximum number of electronic steps."); +GUI_TOOLTIP(vasp_gui.nelm,"NELM: Ch. 6.17 DEFAULT: 60\nMaximum number of electronic steps."); VASP_ENTRY_TABLE(vasp_gui.nelmdl,vasp_gui.calc.nelmdl,"%i","NELMDL=",3,4,0,1); -VASP_TOOLTIP(vasp_gui.nelmdl,"NELMDL: Ch. 6.17 DEFAULT -5(if IALGO=x8)\nSets the number of initial non-selfconsistent steps\ndefault is 0 if ISTART is not 0."); +GUI_TOOLTIP(vasp_gui.nelmdl,"NELMDL: Ch. 6.17 DEFAULT -5(if IALGO=x8)\nSets the number of initial non-selfconsistent steps\ndefault is 0 if ISTART is not 0."); VASP_ENTRY_TABLE(vasp_gui.nelmin,vasp_gui.calc.nelmin,"%i","NELMIN=",4,5,0,1); -VASP_TOOLTIP(vasp_gui.nelmin,"NELMIN: Ch. 6.17 DEFAULT: 2\nMinimum number of electronic steps."); +GUI_TOOLTIP(vasp_gui.nelmin,"NELMIN: Ch. 6.17 DEFAULT: 2\nMinimum number of electronic steps."); /* 2nd line */ VASP_COMBOBOX_TABLE(vasp_gui.mixpre,"MIXPRE=",0,1,1,2); VASP_COMBOBOX_ADD(vasp_gui.mixpre,"0:NONE"); VASP_COMBOBOX_ADD(vasp_gui.mixpre,"1:F=20 INVERSE KERKER"); VASP_COMBOBOX_ADD(vasp_gui.mixpre,"2:F=200 INVERSE KERKER"); -VASP_TOOLTIP(vasp_gui.mixpre,"MIXPRE: Ch. 6.49 DEFAULT: 1\nSelect the preconditioning for Broyden mixing."); +GUI_TOOLTIP(vasp_gui.mixpre,"MIXPRE: Ch. 6.49 DEFAULT: 1\nSelect the preconditioning for Broyden mixing."); /*empty: col1*/ VASP_ENTRY_TABLE(vasp_gui.amix,vasp_gui.calc.amix,"%.4lf","AMIX=",2,3,1,2); -VASP_TOOLTIP(vasp_gui.amix,"AMIX: Ch. 6.49 DEFAULT: 0.4\nlinear mixing parameter\nDefault is 0.8 for ultrasoft pseudopotentials."); +GUI_TOOLTIP(vasp_gui.amix,"AMIX: Ch. 6.49 DEFAULT: 0.4\nlinear mixing parameter\nDefault is 0.8 for ultrasoft pseudopotentials."); VASP_ENTRY_TABLE(vasp_gui.bmix,vasp_gui.calc.bmix,"%.4lf","BMIX=",3,4,1,2); -VASP_TOOLTIP(vasp_gui.bmix,"BMIX: Ch. 6.49 DEFAULT: 1.0\ncutoff wavevector for Kerker mixing."); +GUI_TOOLTIP(vasp_gui.bmix,"BMIX: Ch. 6.49 DEFAULT: 1.0\ncutoff wavevector for Kerker mixing."); VASP_ENTRY_TABLE(vasp_gui.amin,vasp_gui.calc.amin,"%.4lf","AMIN=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.amin,"AMIN: Ch. 6.49 DEFAULT: 0.1\nminimal mixing parameter."); +GUI_TOOLTIP(vasp_gui.amin,"AMIN: Ch. 6.49 DEFAULT: 0.1\nminimal mixing parameter."); /* 3rd line */ VASP_COMBOBOX_TABLE(vasp_gui.inimix,"INIMIX=",0,1,2,3); VASP_COMBOBOX_ADD(vasp_gui.inimix,"0:LINEAR"); VASP_COMBOBOX_ADD(vasp_gui.inimix,"1:KERKER"); -VASP_TOOLTIP(vasp_gui.inimix,"INIMIX: Ch. 6.49 DEFAULT: 1\ntype of initial mixing in Broyden mixing."); +GUI_TOOLTIP(vasp_gui.inimix,"INIMIX: Ch. 6.49 DEFAULT: 1\ntype of initial mixing in Broyden mixing."); VASP_ENTRY_TABLE(vasp_gui.maxmix,vasp_gui.calc.maxmix,"%i","MAXMIX=",1,2,2,3); -VASP_TOOLTIP(vasp_gui.maxmix,"MAXMIX: Ch. 6.49 DEFAULT: -45\nMaximum number of steps stored in Broyden mixer."); +GUI_TOOLTIP(vasp_gui.maxmix,"MAXMIX: Ch. 6.49 DEFAULT: -45\nMaximum number of steps stored in Broyden mixer."); VASP_ENTRY_TABLE(vasp_gui.amix_mag,vasp_gui.calc.amix_mag,"%.4lf","AMIX_MAG=",2,3,2,3); -VASP_TOOLTIP(vasp_gui.amix_mag,"AMIX_MAG: Ch. 6.49 DEFAULT: 1.6\nlinear mixing parameter for magnetization."); +GUI_TOOLTIP(vasp_gui.amix_mag,"AMIX_MAG: Ch. 6.49 DEFAULT: 1.6\nlinear mixing parameter for magnetization."); VASP_ENTRY_TABLE(vasp_gui.bmix_mag,vasp_gui.calc.bmix_mag,"%.4lf","BMIX_MAG=",3,4,2,3); -VASP_TOOLTIP(vasp_gui.bmix_mag,"BMIX_MAG: Ch. 6.49 DEFAULT: 1.0\ncutoff wavevector for Kerker mixing with magnetization."); +GUI_TOOLTIP(vasp_gui.bmix_mag,"BMIX_MAG: Ch. 6.49 DEFAULT: 1.0\ncutoff wavevector for Kerker mixing with magnetization."); VASP_ENTRY_TABLE(vasp_gui.wc,vasp_gui.calc.wc,"%.1lf","WC=",4,5,2,3); -VASP_TOOLTIP(vasp_gui.wc,"WC: Ch. 6.49 DEFAULT: 1000\nstep weight factor for Broyden mixing."); +GUI_TOOLTIP(vasp_gui.wc,"WC: Ch. 6.49 DEFAULT: 1000\nstep weight factor for Broyden mixing."); /* initialize */ VASP_COMBOBOX_SETUP(vasp_gui.mixer,3,vasp_mixer_selected); VASP_COMBOBOX_SETUP(vasp_gui.mixpre,1,vasp_mixpre_selected); @@ -3014,38 +3015,38 @@ VASP_TOOLTIP(vasp_gui.wc,"WC: Ch. 6.49 DEFAULT: 1000\nstep weight factor for Bro VASP_COMBOBOX_ADD(vasp_gui.lreal,"On"); VASP_COMBOBOX_ADD(vasp_gui.lreal,"TRUE"); VASP_COMBOBOX_ADD(vasp_gui.lreal,"FALSE"); -VASP_TOOLTIP(vasp_gui.lreal,"LREAL: Ch. 6.39 DEFAULT: FALSE\nDetermine whether projection operators are evaluated in\nreal-space or reciprocal-space."); +GUI_TOOLTIP(vasp_gui.lreal,"LREAL: Ch. 6.39 DEFAULT: FALSE\nDetermine whether projection operators are evaluated in\nreal-space or reciprocal-space."); /*empty: col2*/ VASP_TEXT_TABLE(vasp_gui.ropt,vasp_gui.calc.ropt,"ROPT=",2,5,0,1); -VASP_TOOLTIP(vasp_gui.ropt,"ROPT: Ch. 6.39 DEFAULT: -\nROPT determine the precision of the real-space operator\nfor LREAL=AUTO and LREAL=On."); +GUI_TOOLTIP(vasp_gui.ropt,"ROPT: Ch. 6.39 DEFAULT: -\nROPT determine the precision of the real-space operator\nfor LREAL=AUTO and LREAL=On."); /* 2nd line */ /*empty: col1*/ VASP_CHECK_TABLE(button,vasp_gui.calc.addgrid,NULL,"ADDGRID",1,2,1,2);/*not calling anything*/ -VASP_TOOLTIP(button,"ADDGRID: Ch. 6.63 DEFAULT: FALSE\nSelect the third fine grid for augmentation charge."); +GUI_TOOLTIP(button,"ADDGRID: Ch. 6.63 DEFAULT: FALSE\nSelect the third fine grid for augmentation charge."); VASP_ENTRY_TABLE(vasp_gui.lmaxmix,vasp_gui.calc.lmaxmix,"%i","LMAXMIX=",2,3,1,2); -VASP_TOOLTIP(vasp_gui.lmaxmix,"LMAXMIX: Ch. 6.63 DEFAULT: 2\nMaximum l-quantum number passed to charge density mixer."); +GUI_TOOLTIP(vasp_gui.lmaxmix,"LMAXMIX: Ch. 6.63 DEFAULT: 2\nMaximum l-quantum number passed to charge density mixer."); /*empty: col4*/ VASP_ENTRY_TABLE(vasp_gui.lmaxpaw,vasp_gui.calc.lmaxpaw,"%i","LMAXPAW=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.lmaxpaw,"LMAXPAW: Ch. 6.63 DEFAULT: 2*lmax\nMaximum l-quantum number for the evaluation of the PAW\non-site terms on the radial grid."); +GUI_TOOLTIP(vasp_gui.lmaxpaw,"LMAXPAW: Ch. 6.63 DEFAULT: 2*lmax\nMaximum l-quantum number for the evaluation of the PAW\non-site terms on the radial grid."); /* 3rd line */ /*empty: col1*/ VASP_CHECK_TABLE(button,vasp_gui.calc.auto_grid,grid_toggle,"AUTO GRID",1,2,2,3); -VASP_TOOLTIP(button,"Automatically sets NG{X,Y,Z}, and NG{X,Y,Z}F."); +GUI_TOOLTIP(button,"Automatically sets NG{X,Y,Z}, and NG{X,Y,Z}F."); VASP_ENTRY_TABLE(vasp_gui.ngx,vasp_gui.calc.ngx,"%i","NGX=",2,3,2,3); -VASP_TOOLTIP(vasp_gui.ngx,"NGX: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the x direction."); +GUI_TOOLTIP(vasp_gui.ngx,"NGX: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the x direction."); VASP_ENTRY_TABLE(vasp_gui.ngy,vasp_gui.calc.ngy,"%i","NGY=",3,4,2,3); -VASP_TOOLTIP(vasp_gui.ngy,"NGY: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the y direction."); +GUI_TOOLTIP(vasp_gui.ngy,"NGY: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the y direction."); VASP_ENTRY_TABLE(vasp_gui.ngz,vasp_gui.calc.ngz,"%i","NGZ=",4,5,2,3); -VASP_TOOLTIP(vasp_gui.ngz,"NGZ: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the z direction."); +GUI_TOOLTIP(vasp_gui.ngz,"NGZ: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the z direction."); /* 4th line */ /*empty: col1*/ /*empty: col2*/ VASP_ENTRY_TABLE(vasp_gui.ngxf,vasp_gui.calc.ngxf,"%i","NGXF=",2,3,3,4); -VASP_TOOLTIP(vasp_gui.ngxf,"NGXF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the x direction."); +GUI_TOOLTIP(vasp_gui.ngxf,"NGXF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the x direction."); VASP_ENTRY_TABLE(vasp_gui.ngyf,vasp_gui.calc.ngyf,"%i","NGYF=",3,4,3,4); -VASP_TOOLTIP(vasp_gui.ngyf,"NGYF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the y direction."); +GUI_TOOLTIP(vasp_gui.ngyf,"NGYF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the y direction."); VASP_ENTRY_TABLE(vasp_gui.ngzf,vasp_gui.calc.ngzf,"%i","NGZF=",4,5,3,4); -VASP_TOOLTIP(vasp_gui.ngzf,"NGZF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the z direction."); +GUI_TOOLTIP(vasp_gui.ngzf,"NGZF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the z direction."); /* initialize */ VASP_COMBOBOX_SETUP(vasp_gui.lreal,3,vasp_lreal_selected); grid_toggle(NULL,NULL); @@ -3065,18 +3066,18 @@ VASP_TOOLTIP(vasp_gui.ngzf,"NGZF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh gr gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ VASP_ENTRY_TABLE(vasp_gui.ismear,vasp_gui.calc.ismear,"%i","ISMEAR=",0,1,0,1); -VASP_TOOLTIP(vasp_gui.ismear,"ISMEAR: Ch. 6.38 DEFAULT: 1\nDetermine how the partial occupations are set.\nIt is advised to change it to ISMEAR=0\nfor semiconducting or insulating materials."); +GUI_TOOLTIP(vasp_gui.ismear,"ISMEAR: Ch. 6.38 DEFAULT: 1\nDetermine how the partial occupations are set.\nIt is advised to change it to ISMEAR=0\nfor semiconducting or insulating materials."); VASP_ENTRY_TABLE(vasp_gui.sigma,vasp_gui.calc.sigma,"%.4lf","SIGMA=",1,2,0,1); -VASP_TOOLTIP(vasp_gui.sigma,"SIGMA: Ch. 6.38 DEFAULT: 0.2\nDetermine the width of the smearing (eV)\nFor ISMEAR=0 (semiconductors or insulators)\na small SIGMA=0.05 can be chosen."); +GUI_TOOLTIP(vasp_gui.sigma,"SIGMA: Ch. 6.38 DEFAULT: 0.2\nDetermine the width of the smearing (eV)\nFor ISMEAR=0 (semiconductors or insulators)\na small SIGMA=0.05 can be chosen."); VASP_CHECK_TABLE(vasp_gui.kgamma,vasp_gui.calc.kgamma,NULL,"KGAMMA",2,3,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.kgamma,"KGAMMA: Ch. 6.4 DEFAULT: TRUE\nWhen KPOINTS file is not present KGAMMA\nindicate if the k-grid is centered around gamma point."); +GUI_TOOLTIP(vasp_gui.kgamma,"KGAMMA: Ch. 6.4 DEFAULT: TRUE\nWhen KPOINTS file is not present KGAMMA\nindicate if the k-grid is centered around gamma point."); VASP_ENTRY_TABLE(vasp_gui.kspacing,vasp_gui.calc.kspacing,"%.4lf","KSPACING=",3,4,0,1); -VASP_TOOLTIP(vasp_gui.kspacing,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS file is not present KSPACING\nDetermine the smallest spacing between k-points (Ang^-1)."); +GUI_TOOLTIP(vasp_gui.kspacing,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS file is not present KSPACING\nDetermine the smallest spacing between k-points (Ang^-1)."); /* 2nd line */ VASP_TEXT_TABLE(vasp_gui.fermwe,vasp_gui.calc.fermwe,"FERMWE=",0,2,1,2); -VASP_TOOLTIP(vasp_gui.fermwe,"FERMWE: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 explicitly sets\noccupancy for each band."); +GUI_TOOLTIP(vasp_gui.fermwe,"FERMWE: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 explicitly sets\noccupancy for each band."); VASP_TEXT_TABLE(vasp_gui.fermdo,vasp_gui.calc.fermdo,"FERMDO=",2,4,1,2); -VASP_TOOLTIP(vasp_gui.fermdo,"FERDO: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 and ISPIN=2 sets\noccupancy for down spin of each band."); +GUI_TOOLTIP(vasp_gui.fermdo,"FERDO: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 and ISPIN=2 sets\noccupancy for down spin of each band."); /* --- end frame */ /* --- spin */ frame = gtk_frame_new("Spin"); @@ -3086,20 +3087,20 @@ VASP_TOOLTIP(vasp_gui.fermdo,"FERDO: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 and ISPIN gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ VASP_CHECK_TABLE(button,vasp_gui.calc.ispin,NULL,"SPIN POLARIZED",0,1,0,1);/*not calling anything*/ -VASP_TOOLTIP(button,"ISPIN: Ch. 6.12 DEFAULT 1\nSpin polarized calculation sets ISPIN=2."); +GUI_TOOLTIP(button,"ISPIN: Ch. 6.12 DEFAULT 1\nSpin polarized calculation sets ISPIN=2."); VASP_CHECK_TABLE(vasp_gui.lnoncoll,vasp_gui.calc.non_collinear,lnoncoll_toggle,"NON COLLINEAR",1,2,0,1); -VASP_TOOLTIP(vasp_gui.lnoncoll,"LNONCOLLINEAR: Ch. 6.68.1 DEFAULT FALSE\nAllow to perform fully, non-collinear\nmagnetic structure calculations."); +GUI_TOOLTIP(vasp_gui.lnoncoll,"LNONCOLLINEAR: Ch. 6.68.1 DEFAULT FALSE\nAllow to perform fully, non-collinear\nmagnetic structure calculations."); VASP_CHECK_TABLE(vasp_gui.lsorbit,vasp_gui.calc.lsorbit,lsorbit_toggle,"LSORBIT",2,3,0,1); - VASP_TOOLTIP(vasp_gui.lsorbit,"LSORBIT: Ch. 6.68.2 DEFAULT: FALSE\nSwitch on spin-orbit coupling (for PAW)\nautomatically sets LNONCOLLINEAR when TRUE."); + GUI_TOOLTIP(vasp_gui.lsorbit,"LSORBIT: Ch. 6.68.2 DEFAULT: FALSE\nSwitch on spin-orbit coupling (for PAW)\nautomatically sets LNONCOLLINEAR when TRUE."); VASP_CHECK_TABLE(button,vasp_gui.calc.gga_compat,NULL,"GGA_COMPAT",3,4,0,1);/*not calling anything*/ -VASP_TOOLTIP(button,"GGA_COMPAT: Ch. 6.42 DEFAULT: TRUE\nRestores the lattice symmetry\nfor gradient corrected functionals."); +GUI_TOOLTIP(button,"GGA_COMPAT: Ch. 6.42 DEFAULT: TRUE\nRestores the lattice symmetry\nfor gradient corrected functionals."); VASP_ENTRY_TABLE(vasp_gui.nupdown,vasp_gui.calc.nupdown,"%.1f","NUPDOWN=",4,5,0,1); -VASP_TOOLTIP(vasp_gui.nupdown,"NUPDOWN: Ch. 6.36 DEFAULT -1\nSets the difference between number\nof electrons in up and down spin component."); +GUI_TOOLTIP(vasp_gui.nupdown,"NUPDOWN: Ch. 6.36 DEFAULT -1\nSets the difference between number\nof electrons in up and down spin component."); /* 2nd line */ VASP_TEXT_TABLE(vasp_gui.magmom,vasp_gui.calc.magmom,"MAGMOM=",0,3,1,2); -VASP_TOOLTIP(vasp_gui.magmom,"MAGMOM: Ch. 6.13 DEFAULT: NIONS\nSets the initial magnetic moment for each atom\nuseful only for calculation with no WAVECAR or CHGCAR\nor magnetic calculations from a non-magnetic start.\nFor non-collinear calculations default value is 3*NIONS."); +GUI_TOOLTIP(vasp_gui.magmom,"MAGMOM: Ch. 6.13 DEFAULT: NIONS\nSets the initial magnetic moment for each atom\nuseful only for calculation with no WAVECAR or CHGCAR\nor magnetic calculations from a non-magnetic start.\nFor non-collinear calculations default value is 3*NIONS."); VASP_TEXT_TABLE(vasp_gui.saxis,vasp_gui.calc.saxis,"SAXIS=",3,5,1,2); -VASP_TOOLTIP(vasp_gui.saxis,"SAXIS: Ch. 6.68.2 DEFAULT -\nSets the quantisation axis for spin.\nThe default is SAXIS = eps 0 1\nwhere eps is a small quantity."); +GUI_TOOLTIP(vasp_gui.saxis,"SAXIS: Ch. 6.68.2 DEFAULT -\nSets the quantisation axis for spin.\nThe default is SAXIS = eps 0 1\nwhere eps is a small quantity."); /* --- end frame */ /* --- exchange correlation */ frame = gtk_frame_new("Exchange Correlation"); @@ -3115,9 +3116,9 @@ VASP_TOOLTIP(vasp_gui.saxis,"SAXIS: Ch. 6.68.2 DEFAULT -\nSets the quantisation VASP_COMBOBOX_ADD(vasp_gui.gga,"RP:rPBE"); VASP_COMBOBOX_ADD(vasp_gui.gga,"AM:AM05"); VASP_COMBOBOX_ADD(vasp_gui.gga,"PS:PBEsol"); -VASP_TOOLTIP(vasp_gui.gga,"GGA: Ch. 6.40 DEFAULT -\nSets the gradient corrected functional.\nThe default is selected according to the POTCAR file."); +GUI_TOOLTIP(vasp_gui.gga,"GGA: Ch. 6.40 DEFAULT -\nSets the gradient corrected functional.\nThe default is selected according to the POTCAR file."); VASP_CHECK_TABLE(button,vasp_gui.calc.voskown,NULL,"VOSKOWN",1,2,0,1);/*not calling anything*/ -VASP_TOOLTIP(button,"VOSKOWN: Ch. 6.41 DEFAULT 0\nSets the Vosko, Wilk and Nusair method\nfor interpolation of correlation functional).\nUseful only if GGA=91 (PW91)."); +GUI_TOOLTIP(button,"VOSKOWN: Ch. 6.41 DEFAULT 0\nSets the Vosko, Wilk and Nusair method\nfor interpolation of correlation functional).\nUseful only if GGA=91 (PW91)."); /*empty: col2*/ /*empty: col3*/ /*empty: col4*/ @@ -3127,42 +3128,42 @@ VASP_TOOLTIP(button,"VOSKOWN: Ch. 6.41 DEFAULT 0\nSets the Vosko, Wilk and Nusai VASP_COMBOBOX_ADD(vasp_gui.metagga,"rTPSS"); VASP_COMBOBOX_ADD(vasp_gui.metagga,"M06L"); VASP_COMBOBOX_ADD(vasp_gui.metagga,"MBJ"); -VASP_TOOLTIP(vasp_gui.metagga,"METAGGA: Ch. 6.43 DEFAULT none\nSets the meta-GGA functional."); +GUI_TOOLTIP(vasp_gui.metagga,"METAGGA: Ch. 6.43 DEFAULT none\nSets the meta-GGA functional."); VASP_CHECK_TABLE(button,vasp_gui.calc.lmetagga,metagga_toggle,"LMETAGGA",1,2,1,2); -VASP_TOOLTIP(button,"LMETAGGA (secret) DEFAULT FALSE\nIgnored (but recognized and read) by VASP.\nUsed (here) to enable a METAGGA calculation."); +GUI_TOOLTIP(button,"LMETAGGA (secret) DEFAULT FALSE\nIgnored (but recognized and read) by VASP.\nUsed (here) to enable a METAGGA calculation."); VASP_CHECK_TABLE(button,vasp_gui.calc.lasph,NULL,"LASPH",2,3,1,2);/*not calling anything*/ -VASP_TOOLTIP(button,"LASPH: Ch. 6.44 DEFAULT FALSE\nSets calculation of non-spherical contributions\nfrom the gradient corrections in PAW spheres."); +GUI_TOOLTIP(button,"LASPH: Ch. 6.44 DEFAULT FALSE\nSets calculation of non-spherical contributions\nfrom the gradient corrections in PAW spheres."); VASP_CHECK_TABLE(button,vasp_gui.calc.lmixtau,NULL,"LMIXTAU",3,4,1,2);/*not calling anything*/ -VASP_TOOLTIP(button,"LMIXTAU: Ch. 6.43.2 DEFAULT FALSE\nSets inclusion of kinetic energy density\nto the mixer (useful to converge METAGGA)."); +GUI_TOOLTIP(button,"LMIXTAU: Ch. 6.43.2 DEFAULT FALSE\nSets inclusion of kinetic energy density\nto the mixer (useful to converge METAGGA)."); VASP_ENTRY_TABLE(vasp_gui.lmaxtau,vasp_gui.calc.lmaxtau,"%i","LMAXTAU=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.lmaxtau,"LMAXTAU: Ch. 6.43.1 DEFAULT 0\nSets maximum l-quantum number\nto calculate PAW one-center expansion\nof the kinetic energy density.\nDefault is 6 if LASPH is set to TRUE."); +GUI_TOOLTIP(vasp_gui.lmaxtau,"LMAXTAU: Ch. 6.43.1 DEFAULT 0\nSets maximum l-quantum number\nto calculate PAW one-center expansion\nof the kinetic energy density.\nDefault is 6 if LASPH is set to TRUE."); /* 3rd line */ VASP_TEXT_TABLE(vasp_gui.cmbj,vasp_gui.calc.cmbj,"CMBJ=",0,3,2,3); -VASP_TOOLTIP(vasp_gui.cmbj,"CMBJ: Ch 6.43 DEFAULT: -\nFor MBJ meta-GGA calculations CMBJ\nsets the mixing coefficient for Becke-Roussel potential\nfor each species or constant if CMBJ has only one value."); +GUI_TOOLTIP(vasp_gui.cmbj,"CMBJ: Ch 6.43 DEFAULT: -\nFor MBJ meta-GGA calculations CMBJ\nsets the mixing coefficient for Becke-Roussel potential\nfor each species or constant if CMBJ has only one value."); VASP_ENTRY_TABLE(vasp_gui.cmbja,vasp_gui.calc.cmbja,"%.4lf","CMBJA=",3,4,2,3); -VASP_TOOLTIP(vasp_gui.cmbja,"CMBJA: Ch. 6.43 DEFAULT -0.012\nAlpha parameter to calculate CMBJ\nSelfconsistently at each electronic step.\nUnused if CMBJ is specified."); +GUI_TOOLTIP(vasp_gui.cmbja,"CMBJA: Ch. 6.43 DEFAULT -0.012\nAlpha parameter to calculate CMBJ\nSelfconsistently at each electronic step.\nUnused if CMBJ is specified."); VASP_ENTRY_TABLE(vasp_gui.cmbjb,vasp_gui.calc.cmbjb,"%.4lf","CMBJB=",4,5,2,3); -VASP_TOOLTIP(vasp_gui.cmbjb,"CMBJB: Ch. 6.43 DEFAULT 1.023\nBeta parameter to calculate CMBJ\nSelfconsistently at each electronic step.\nUnused if CMBJ is specified."); +GUI_TOOLTIP(vasp_gui.cmbjb,"CMBJB: Ch. 6.43 DEFAULT 1.023\nBeta parameter to calculate CMBJ\nSelfconsistently at each electronic step.\nUnused if CMBJ is specified."); /* 4th line */ VASP_COMBOBOX_TABLE(vasp_gui.ldau,"LDAUTYPE=",0,1,3,4); VASP_COMBOBOX_ADD(vasp_gui.ldau,"1:LSDA+U Liechtenstein"); VASP_COMBOBOX_ADD(vasp_gui.ldau,"2:LSDA+U Dudarev"); VASP_COMBOBOX_ADD(vasp_gui.ldau,"4:LDA+U Liechtenstein"); -VASP_TOOLTIP(vasp_gui.ldau,"LDAUTYPE: Ch. 6.70 DEFAULT: 2\nSets the type of L(S)DA+U calculation."); +GUI_TOOLTIP(vasp_gui.ldau,"LDAUTYPE: Ch. 6.70 DEFAULT: 2\nSets the type of L(S)DA+U calculation."); VASP_CHECK_TABLE(button,vasp_gui.calc.ldau,ldau_toggle,"LDAU",1,2,3,4); -VASP_TOOLTIP(button,"LDAU: Ch. 6.70 DEFAULT: FALSE\nSwitches on L(S)DA+U calculation."); +GUI_TOOLTIP(button,"LDAU: Ch. 6.70 DEFAULT: FALSE\nSwitches on L(S)DA+U calculation."); VASP_TEXT_TABLE(vasp_gui.ldaul,vasp_gui.calc.ldaul,"LDAUL=",2,5,3,4); -VASP_TOOLTIP(vasp_gui.ldaul,"LDAUL: Ch. 6.70 DEFAULT: 2\nSets the l-quantum number (for each species)\nfor which the on-site interaction is added."); +GUI_TOOLTIP(vasp_gui.ldaul,"LDAUL: Ch. 6.70 DEFAULT: 2\nSets the l-quantum number (for each species)\nfor which the on-site interaction is added."); /* 5th line */ VASP_COMBOBOX_TABLE(vasp_gui.ldau_print,"LDAUPRINT=",0,1,4,5); VASP_COMBOBOX_ADD(vasp_gui.ldau_print,"0:Silent"); VASP_COMBOBOX_ADD(vasp_gui.ldau_print,"1:Occupancy matrix"); VASP_COMBOBOX_ADD(vasp_gui.ldau_print,"2:Full output"); -VASP_TOOLTIP(vasp_gui.ldau_print,"LDAUPRINT: Ch. 6.70 DEFAULT 0\nSets the level of verbosity of L(S)DA+U."); +GUI_TOOLTIP(vasp_gui.ldau_print,"LDAUPRINT: Ch. 6.70 DEFAULT 0\nSets the level of verbosity of L(S)DA+U."); VASP_TEXT_TABLE(vasp_gui.ldauu,vasp_gui.calc.ldauu,"LDAUU=",1,3,4,5); -VASP_TOOLTIP(vasp_gui.ldauu,"LDAUU: Ch. 6.70 DEFAULT: -\nSets effective on-site Coulomb interaction (for each species)."); +GUI_TOOLTIP(vasp_gui.ldauu,"LDAUU: Ch. 6.70 DEFAULT: -\nSets effective on-site Coulomb interaction (for each species)."); VASP_TEXT_TABLE(vasp_gui.ldauj,vasp_gui.calc.ldauj,"LDAUJ=",3,5,4,5); -VASP_TOOLTIP(vasp_gui.ldauj,"LDAUJ: Ch. 6.70 DEFAULT: -\nSets effective on-site Exchange interaction (for each species)."); +GUI_TOOLTIP(vasp_gui.ldauj,"LDAUJ: Ch. 6.70 DEFAULT: -\nSets effective on-site Exchange interaction (for each species)."); /* initialize */ VASP_COMBOBOX_SETUP(vasp_gui.gga,1,vasp_gga_selected); VASP_COMBOBOX_SETUP(vasp_gui.metagga,3,vasp_metagga_selected); @@ -3185,21 +3186,21 @@ VASP_TOOLTIP(vasp_gui.ldauj,"LDAUJ: Ch. 6.70 DEFAULT: -\nSets effective on-site VASP_COMBOBOX_ADD(vasp_gui.idipol,"2:v axis"); VASP_COMBOBOX_ADD(vasp_gui.idipol,"3:w axis"); VASP_COMBOBOX_ADD(vasp_gui.idipol,"4:all axis"); -VASP_TOOLTIP(vasp_gui.idipol,"IDIPOL: Ch. 6.64 DEFAULT: -\nSets the direction of the calculated dipole moment\nparallel to the 1st (1), 2nd (2) or 3rd (3) lattice vector.\nIDIPOL=4 trigger full dipole calculation\n0 switches off dipole calculation (remove IDIPOL)."); +GUI_TOOLTIP(vasp_gui.idipol,"IDIPOL: Ch. 6.64 DEFAULT: -\nSets the direction of the calculated dipole moment\nparallel to the 1st (1), 2nd (2) or 3rd (3) lattice vector.\nIDIPOL=4 trigger full dipole calculation\n0 switches off dipole calculation (remove IDIPOL)."); VASP_CHECK_TABLE(vasp_gui.ldipol,vasp_gui.calc.ldipol,NULL,"LDIPOL",1,2,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.ldipol,"LDIPOL: Ch. 6.64 DEFAULT: FALSE\nSets potential dipole correction of the\nslab/molecule periodic-boundary induced errors."); +GUI_TOOLTIP(vasp_gui.ldipol,"LDIPOL: Ch. 6.64 DEFAULT: FALSE\nSets potential dipole correction of the\nslab/molecule periodic-boundary induced errors."); VASP_CHECK_TABLE(vasp_gui.lmono,vasp_gui.calc.lmono,NULL,"LMONO",2,3,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.lmono,"LMONO: Ch. 6.64 DEFAULT: FALSE\nSets potential monopole correction of the\nslab/molecule periodic-boundary induced errors."); +GUI_TOOLTIP(vasp_gui.lmono,"LMONO: Ch. 6.64 DEFAULT: FALSE\nSets potential monopole correction of the\nslab/molecule periodic-boundary induced errors."); VASP_TEXT_TABLE(vasp_gui.dipol,vasp_gui.calc.dipol,"DIPOL=",3,5,0,1); -VASP_TOOLTIP(vasp_gui.dipol,"DIPOL: Ch. 6.64 DEFAULT: -\nSets the center of the net charge distribution.\nIf left blank a guess value is sets at runtime."); +GUI_TOOLTIP(vasp_gui.dipol,"DIPOL: Ch. 6.64 DEFAULT: -\nSets the center of the net charge distribution.\nIf left blank a guess value is sets at runtime."); /* 2nd line */ /*empty: col0*/ /*empty: col1*/ /*empty: col2*/ VASP_ENTRY_TABLE(vasp_gui.epsilon,vasp_gui.calc.epsilon,"%.4lf","EPSILON=",3,4,2,3); -VASP_TOOLTIP(vasp_gui.epsilon,"EPSILON: Ch. 6.64 DEFAULT: 1\nSets the dielectric constant of the medium."); +GUI_TOOLTIP(vasp_gui.epsilon,"EPSILON: Ch. 6.64 DEFAULT: 1\nSets the dielectric constant of the medium."); VASP_ENTRY_TABLE(vasp_gui.efield,vasp_gui.calc.efield,"%.4lf","EFIELD=",4,5,2,3); -VASP_TOOLTIP(vasp_gui.efield,"EFIELD: Ch. 6.64 DEFAULT: 0\nApply an external electrostatic field\nin a slab, or molecule calculation.\nOnly a single component can be given\nparallel to IDIPOL direction (1-3)."); +GUI_TOOLTIP(vasp_gui.efield,"EFIELD: Ch. 6.64 DEFAULT: 0\nApply an external electrostatic field\nin a slab, or molecule calculation.\nOnly a single component can be given\nparallel to IDIPOL direction (1-3)."); /*initialize sensitive widget*/ VASP_COMBOBOX_SETUP(vasp_gui.idipol,0,vasp_idipol_selected); if(vasp_gui.calc.idipol!=VID_0) { @@ -3238,22 +3239,22 @@ if(vasp_gui.calc.idipol!=VID_0) { VASP_COMBOBOX_ADD(vasp_gui.lorbit,"10:PROCAR"); VASP_COMBOBOX_ADD(vasp_gui.lorbit,"11:lm-PROCAR"); VASP_COMBOBOX_ADD(vasp_gui.lorbit,"12:phase+lm-PROCAR"); -VASP_TOOLTIP(vasp_gui.lorbit,"LORBIT: Ch. 6.34 DEFAULT: 0\nSets the spd- and site projected\nwavefunction character of each band\nand the local partial DOS."); +GUI_TOOLTIP(vasp_gui.lorbit,"LORBIT: Ch. 6.34 DEFAULT: 0\nSets the spd- and site projected\nwavefunction character of each band\nand the local partial DOS."); VASP_ENTRY_TABLE(vasp_gui.nedos,vasp_gui.calc.nedos,"%i","NEDOS=",1,2,0,1); -VASP_TOOLTIP(vasp_gui.nedos,"NEDOS: Ch. 6.37 DEFAULT: 301\nNumber of points for which DOS is calculated."); +GUI_TOOLTIP(vasp_gui.nedos,"NEDOS: Ch. 6.37 DEFAULT: 301\nNumber of points for which DOS is calculated."); VASP_ENTRY_TABLE(vasp_gui.emin,vasp_gui.calc.emin,"%.2lf","EMIN=",2,3,0,1); -VASP_TOOLTIP(vasp_gui.emin,"EMIN: Ch. 6.37 DEFAULT: low eig-eps\nSets the smallest energy for which DOS is calculated.\nDefault is lowest Kohn-Sham eigenvalue minus a small quantity."); +GUI_TOOLTIP(vasp_gui.emin,"EMIN: Ch. 6.37 DEFAULT: low eig-eps\nSets the smallest energy for which DOS is calculated.\nDefault is lowest Kohn-Sham eigenvalue minus a small quantity."); VASP_ENTRY_TABLE(vasp_gui.emax,vasp_gui.calc.emax,"%.2lf","EMAX=",3,4,0,1); -VASP_TOOLTIP(vasp_gui.emax,"EMAX: Ch. 6.37 DEFAULT: high eig+eps\nSets the highest energy for which DOS is calculated.\nDefault is highest Kohn-Sham eigenvalue plus a small quantity."); +GUI_TOOLTIP(vasp_gui.emax,"EMAX: Ch. 6.37 DEFAULT: high eig+eps\nSets the highest energy for which DOS is calculated.\nDefault is highest Kohn-Sham eigenvalue plus a small quantity."); VASP_ENTRY_TABLE(vasp_gui.efermi,vasp_gui.calc.efermi,"%.2lf","EFERMI=",4,5,0,1); -VASP_TOOLTIP(vasp_gui.efermi,"EFERMI: (secret) DEFAULT: EREF\nSets initial Fermi energy before it is calculated.\nUsually there is no use to change this setting.\nEREF is actually another \"secret\" parameter."); +GUI_TOOLTIP(vasp_gui.efermi,"EFERMI: (secret) DEFAULT: EREF\nSets initial Fermi energy before it is calculated.\nUsually there is no use to change this setting.\nEREF is actually another \"secret\" parameter."); /* 2nd line */ VASP_LABEL_TABLE("(LORBIT>5) => Req. PAW",0,1,1,2); VASP_CHECK_TABLE(vasp_gui.have_paw,vasp_gui.calc.have_paw,NULL,"HAVE PAW",1,2,1,2);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.have_paw,"Is set if a PAW POTCAR file is detected."); +GUI_TOOLTIP(vasp_gui.have_paw,"Is set if a PAW POTCAR file is detected."); gtk_widget_set_sensitive(vasp_gui.have_paw,FALSE);/*just an indication*/ VASP_TEXT_TABLE(vasp_gui.rwigs,vasp_gui.calc.rwigs,"RWIGS=",2,5,1,2); -VASP_TOOLTIP(vasp_gui.rwigs,"RWIGS: Ch. 6.33 DEFAULT: -\nSets the Wigner Seitz radius for each species.\nDefault value is read from POTCAR."); +GUI_TOOLTIP(vasp_gui.rwigs,"RWIGS: Ch. 6.33 DEFAULT: -\nSets the Wigner Seitz radius for each species.\nDefault value is read from POTCAR."); /* initialize */ if(vasp_gui.calc.have_paw) VASP_COMBOBOX_SETUP(vasp_gui.lorbit,4,vasp_lorbit_selected); else VASP_COMBOBOX_SETUP(vasp_gui.lorbit,0,vasp_lorbit_selected); @@ -3266,15 +3267,15 @@ else VASP_COMBOBOX_SETUP(vasp_gui.lorbit,0,vasp_lorbit_selected); gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ VASP_CHECK_TABLE(vasp_gui.loptics,vasp_gui.calc.loptics,NULL,"LOPTICS",0,1,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.loptics,"LOPTICS: Ch. 6.72.1 DEFAULT: FALSE\nSwitch frequency dependent dielectric matrix calculation\nover a grid determined by NEDOS.\nIt is advised to increase NEDOS & NBANDS."); +GUI_TOOLTIP(vasp_gui.loptics,"LOPTICS: Ch. 6.72.1 DEFAULT: FALSE\nSwitch frequency dependent dielectric matrix calculation\nover a grid determined by NEDOS.\nIt is advised to increase NEDOS & NBANDS."); VASP_CHECK_TABLE(vasp_gui.lepsilon,vasp_gui.calc.lepsilon,NULL,"LEPSILON",1,2,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.lepsilon,"LEPSILON: Ch. 6.72.4 DEFAULT: FALSE\nSwitch dielectric matrix calculation using\ndensity functional perturbation theory.\nConcurrent to LOPTICS, it is not recommended\nto run both at the same time."); +GUI_TOOLTIP(vasp_gui.lepsilon,"LEPSILON: Ch. 6.72.4 DEFAULT: FALSE\nSwitch dielectric matrix calculation using\ndensity functional perturbation theory.\nConcurrent to LOPTICS, it is not recommended\nto run both at the same time."); VASP_CHECK_TABLE(vasp_gui.lrpa,vasp_gui.calc.lrpa,NULL,"LRPA",2,3,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.lrpa,"LRPA: Ch. 6.72.5 DEFAULT: FALSE\nSwitch local field effects calculation\non the Hartree level only (no XC)."); +GUI_TOOLTIP(vasp_gui.lrpa,"LRPA: Ch. 6.72.5 DEFAULT: FALSE\nSwitch local field effects calculation\non the Hartree level only (no XC)."); VASP_CHECK_TABLE(vasp_gui.lnabla,vasp_gui.calc.lnabla,NULL,"LNABLA",3,4,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.lnabla,"LNABLA: Ch. 6.72.3 DEFAULT: FALSE\nSwitch to the simple transversal expressions\nof the frequency dependent dielectric matrix.\nUsually there is no use to change this setting."); +GUI_TOOLTIP(vasp_gui.lnabla,"LNABLA: Ch. 6.72.3 DEFAULT: FALSE\nSwitch to the simple transversal expressions\nof the frequency dependent dielectric matrix.\nUsually there is no use to change this setting."); VASP_ENTRY_TABLE(vasp_gui.cshift,vasp_gui.calc.cshift,"%.2lf","CSHIFT=",4,5,0,1); -VASP_TOOLTIP(vasp_gui.cshift,"CSHIFT: Ch. 6.72.2 DEFAULT: 0.1\nSets the complex shift \%nu of the Kramers-Kronig\ntransformation of the dielectric function.\nIf CSHIFT is decreased, NEDOS should be increased."); +GUI_TOOLTIP(vasp_gui.cshift,"CSHIFT: Ch. 6.72.2 DEFAULT: 0.1\nSets the complex shift \%nu of the Kramers-Kronig\ntransformation of the dielectric function.\nIf CSHIFT is decreased, NEDOS should be increased."); /* --- end frame */ @@ -3303,15 +3304,15 @@ VASP_TOOLTIP(vasp_gui.cshift,"CSHIFT: Ch. 6.72.2 DEFAULT: 0.1\nSets the complex VASP_COMBOBOX_ADD(vasp_gui.ibrion,"7:Perturbation Theory"); VASP_COMBOBOX_ADD(vasp_gui.ibrion,"8:Pert. Theory with SYM"); VASP_COMBOBOX_ADD(vasp_gui.ibrion,"44:Transition State"); -VASP_TOOLTIP(vasp_gui.ibrion,"IBRION: Ch. 6.22 DEFAULT -1\nSets the algorithm for the ions motion.\nDefault is IBRION=0 if NSW>1."); +GUI_TOOLTIP(vasp_gui.ibrion,"IBRION: Ch. 6.22 DEFAULT -1\nSets the algorithm for the ions motion.\nDefault is IBRION=0 if NSW>1."); VASP_ENTRY_TABLE(vasp_gui.nsw,vasp_gui.calc.nsw,"%i","NSW=",1,2,0,1); -VASP_TOOLTIP(vasp_gui.nsw,"NSW: Ch. 6.20 DEFAULT 0\nSet the maximum number of ionic steps."); +GUI_TOOLTIP(vasp_gui.nsw,"NSW: Ch. 6.20 DEFAULT 0\nSet the maximum number of ionic steps."); VASP_ENTRY_TABLE(vasp_gui.ediffg,vasp_gui.calc.ediffg,"%.2E","EDIFFG=",2,3,0,1); -VASP_TOOLTIP(vasp_gui.ediffg,"EDIFFG: Ch. 6.19 DEFAULT EDIFF*10\nSets the energy criterion for ending ionic relaxation\n>0 value are for energy difference (eV)\n<0 values are for absolute forces value (eV/Ang)."); +GUI_TOOLTIP(vasp_gui.ediffg,"EDIFFG: Ch. 6.19 DEFAULT EDIFF*10\nSets the energy criterion for ending ionic relaxation\n>0 value are for energy difference (eV)\n<0 values are for absolute forces value (eV/Ang)."); VASP_ENTRY_TABLE(vasp_gui.potim,vasp_gui.calc.potim,"%.4lf","POTIM=",3,4,0,1); -VASP_TOOLTIP(vasp_gui.potim,"POTIM: Ch. 6.23 DEFAULT 0.5\nFor IBRION=0 (MD) sets time step (fs)\nfor IBRION=1-3 sets force scaling constant."); +GUI_TOOLTIP(vasp_gui.potim,"POTIM: Ch. 6.23 DEFAULT 0.5\nFor IBRION=0 (MD) sets time step (fs)\nfor IBRION=1-3 sets force scaling constant."); VASP_ENTRY_TABLE(vasp_gui.pstress,vasp_gui.calc.pstress,"%.4lf","PSTRESS=",4,5,0,1); -VASP_TOOLTIP(vasp_gui.pstress,"PSTRESS: Ch. 6.25 DEFAULT 0\nSets the Pulay stress correction (kBar)\nalso used to set an external pressure."); +GUI_TOOLTIP(vasp_gui.pstress,"PSTRESS: Ch. 6.25 DEFAULT 0\nSets the Pulay stress correction (kBar)\nalso used to set an external pressure."); /* 2nd line */ VASP_COMBOBOX_TABLE(vasp_gui.isif,"ISIF=",0,1,1,2); VASP_COMBOBOX_ADD(vasp_gui.isif,"0:F_0_I_0_0"); @@ -3322,15 +3323,15 @@ VASP_TOOLTIP(vasp_gui.pstress,"PSTRESS: Ch. 6.25 DEFAULT 0\nSets the Pulay stres VASP_COMBOBOX_ADD(vasp_gui.isif,"5:F_S_0_S_0"); VASP_COMBOBOX_ADD(vasp_gui.isif,"6:F_S_0_S_V"); VASP_COMBOBOX_ADD(vasp_gui.isif,"7:F_S_0_0_V"); -VASP_TOOLTIP(vasp_gui.isif,"ISIF: Ch. 6.24 DEFAULT 2\nSwitch to calculate F(force) and S(stress)\nand to relax I(ion) S(cell shape) and V(cell voume)\n0 = no calcul/no relaxation P = only total Pressure\nDefault is 0(F_0_I_0_0) if IBRION=0."); +GUI_TOOLTIP(vasp_gui.isif,"ISIF: Ch. 6.24 DEFAULT 2\nSwitch to calculate F(force) and S(stress)\nand to relax I(ion) S(cell shape) and V(cell voume)\n0 = no calcul/no relaxation P = only total Pressure\nDefault is 0(F_0_I_0_0) if IBRION=0."); VASP_CHECK_TABLE(vasp_gui.relax_ions,vasp_gui.rions,isif_toggle,"atom positions",1,2,1,2); -VASP_TOOLTIP(vasp_gui.relax_ions,"Switches atomic relaxation.\nUpdates ISIF accordingly (but not IBRION)."); +GUI_TOOLTIP(vasp_gui.relax_ions,"Switches atomic relaxation.\nUpdates ISIF accordingly (but not IBRION)."); VASP_CHECK_TABLE(vasp_gui.relax_shape,vasp_gui.rshape,isif_toggle,"cell shape",2,3,1,2); -VASP_TOOLTIP(vasp_gui.relax_ions,"Switches cell shape relaxation.\nUpdates ISIF accordingly (but not IBRION)."); +GUI_TOOLTIP(vasp_gui.relax_ions,"Switches cell shape relaxation.\nUpdates ISIF accordingly (but not IBRION)."); VASP_CHECK_TABLE(vasp_gui.relax_volume,vasp_gui.rvolume,isif_toggle,"cell volume",3,4,1,2); -VASP_TOOLTIP(vasp_gui.relax_ions,"Switches cell volume relaxation.\nUpdates ISIF accordingly (but not IBRION)."); +GUI_TOOLTIP(vasp_gui.relax_ions,"Switches cell volume relaxation.\nUpdates ISIF accordingly (but not IBRION)."); VASP_ENTRY_TABLE(vasp_gui.nfree,vasp_gui.calc.nfree,"%i","NFREE=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.nfree,"NFREE: Ch. 6.22 DEFAULT: -\nSets the number of ionic steps kept in history\nfor IBRION=1 Quasi-Newton algorithm.\nFor finite difference IBRION=5-6 NFREE\nsets the number of displacement/direction/atom."); +GUI_TOOLTIP(vasp_gui.nfree,"NFREE: Ch. 6.22 DEFAULT: -\nSets the number of ionic steps kept in history\nfor IBRION=1 Quasi-Newton algorithm.\nFor finite difference IBRION=5-6 NFREE\nsets the number of displacement/direction/atom."); /* initialize */ VASP_COMBOBOX_SETUP(vasp_gui.ibrion,0,vasp_ibrion_selected); VASP_COMBOBOX_SETUP(vasp_gui.isif,0,vasp_isif_selected); @@ -3346,22 +3347,22 @@ VASP_TOOLTIP(vasp_gui.nfree,"NFREE: Ch. 6.22 DEFAULT: -\nSets the number of ioni label = gtk_label_new("SET IBRION=0 FOR MD"); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,2); VASP_ENTRY_TABLE(vasp_gui.tebeg,vasp_gui.calc.tebeg,"%.1lf","TEBEG=",1,2,0,1); -VASP_TOOLTIP(vasp_gui.tebeg,"TEBEG: Ch. 6.29 DEFAULT: 0\nSets the start temperature of MD run.\nTo be corrected by (Nion-1)/Nion."); +GUI_TOOLTIP(vasp_gui.tebeg,"TEBEG: Ch. 6.29 DEFAULT: 0\nSets the start temperature of MD run.\nTo be corrected by (Nion-1)/Nion."); VASP_ENTRY_TABLE(vasp_gui.teend,vasp_gui.calc.teend,"%.1lf","TEEND=",2,3,0,1); -VASP_TOOLTIP(vasp_gui.teend,"TEEND: Ch. 6.29 DEFAULT: TEBEG\nSets the end temperature of MD run.\nTo be corrected by (Nion-1)/Nion."); +GUI_TOOLTIP(vasp_gui.teend,"TEEND: Ch. 6.29 DEFAULT: TEBEG\nSets the end temperature of MD run.\nTo be corrected by (Nion-1)/Nion."); VASP_ENTRY_TABLE(vasp_gui.smass,vasp_gui.calc.smass,"%.1lf","SMASS=",3,4,0,1); -VASP_TOOLTIP(vasp_gui.smass,"SMASS: Ch. 6.30 DEFAULT 0\nControls the velocities during MD.\nFor IBRION=3 SMASS is used as a damping factor."); +GUI_TOOLTIP(vasp_gui.smass,"SMASS: Ch. 6.30 DEFAULT 0\nControls the velocities during MD.\nFor IBRION=3 SMASS is used as a damping factor."); /*empty: col4*/ /* 2nd line */ /*occ: col0*/ VASP_ENTRY_TABLE(vasp_gui.nblock,vasp_gui.calc.nblock,"%i","NBLOCK=",1,2,1,2); -VASP_TOOLTIP(vasp_gui.nblock,"NBLOCK: Ch. 6.21 DEFAULT: 1\nSets number of steps after which DOS/pair correlation\nfunction are calculated, and XDATCAR updated.\nFor SMASS=-1 kinetic energy is scaled every NBLOCK."); +GUI_TOOLTIP(vasp_gui.nblock,"NBLOCK: Ch. 6.21 DEFAULT: 1\nSets number of steps after which DOS/pair correlation\nfunction are calculated, and XDATCAR updated.\nFor SMASS=-1 kinetic energy is scaled every NBLOCK."); VASP_ENTRY_TABLE(vasp_gui.kblock,vasp_gui.calc.kblock,"%i","KBLOCK=",2,3,1,2); -VASP_TOOLTIP(vasp_gui.kblock,"KBLOCK: Ch. 6.21 DEFAULT: NSW\nAfter KBLOCK*NBLOCK iterations DOS and\naverage pair correlation function is written\nto DOSCAR and PCDAT, respectively."); +GUI_TOOLTIP(vasp_gui.kblock,"KBLOCK: Ch. 6.21 DEFAULT: NSW\nAfter KBLOCK*NBLOCK iterations DOS and\naverage pair correlation function is written\nto DOSCAR and PCDAT, respectively."); VASP_ENTRY_TABLE(vasp_gui.npaco,vasp_gui.calc.npaco,"%i","NPACO=",3,4,1,2); -VASP_TOOLTIP(vasp_gui.npaco,"NPACO Ch. 6.31 DEFAULT: 256\nNumber of slots of pair correlation function."); +GUI_TOOLTIP(vasp_gui.npaco,"NPACO Ch. 6.31 DEFAULT: 256\nNumber of slots of pair correlation function."); VASP_ENTRY_TABLE(vasp_gui.apaco,vasp_gui.calc.apaco,"%.4lf","APACO=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.apaco,"APACO: Ch. 6.31 DEFAULT: 16\nMax distance (Ang) for calculation\nof pair correlation function."); +GUI_TOOLTIP(vasp_gui.apaco,"APACO: Ch. 6.31 DEFAULT: 16\nMax distance (Ang) for calculation\nof pair correlation function."); /* initialize sensitive widget*/ if (vasp_gui.calc.ibrion==0) {/*selecting MD enable molecular dynamics settings*/ gtk_widget_set_sensitive(vasp_gui.tebeg,TRUE); @@ -3392,52 +3393,52 @@ VASP_TOOLTIP(vasp_gui.apaco,"APACO: Ch. 6.31 DEFAULT: 16\nMax distance (Ang) for VASP_COMBOBOX_ADD(vasp_gui.poscar_free,"All atom FIXED"); VASP_COMBOBOX_ADD(vasp_gui.poscar_free,"All atom FREE"); VASP_COMBOBOX_ADD(vasp_gui.poscar_free,"Manual selection"); -VASP_TOOLTIP(vasp_gui.poscar_free,"Set position tags to \"F F F\" (FIXED)\n\"T T T\" (FREE) or user modifications."); +GUI_TOOLTIP(vasp_gui.poscar_free,"Set position tags to \"F F F\" (FIXED)\n\"T T T\" (FREE) or user modifications."); VASP_CHECK_TABLE(button,vasp_gui.calc.poscar_sd,toggle_poscar_sd,"Sel. Dynamics",1,2,0,1); -VASP_TOOLTIP(button,"Allow use of tags for ion motion (Ch. 5.7)."); +GUI_TOOLTIP(button,"Allow use of tags for ion motion (Ch. 5.7)."); VASP_ENTRY_TABLE(vasp_gui.isym,vasp_gui.calc.isym,"%i","ISYM=",2,3,0,1); -VASP_TOOLTIP(vasp_gui.isym,"ISYM: Ch. 6.27 DEFAULT 2\nSwitch symmetry method (0=OFF)\nDefault is 1 for ultrasoft, 2 for PAW PP."); +GUI_TOOLTIP(vasp_gui.isym,"ISYM: Ch. 6.27 DEFAULT 2\nSwitch symmetry method (0=OFF)\nDefault is 1 for ultrasoft, 2 for PAW PP."); VASP_ENTRY_TABLE(vasp_gui.sym_prec,vasp_gui.calc.sym_prec,"%.2lE","_PREC=",3,4,0,1); -VASP_TOOLTIP(vasp_gui.sym_prec,"SYMPREC: Ch. 6.27 DEFAULT 10^-5\nSets the accuracy of ion positions\nin determining the system symmetry."); +GUI_TOOLTIP(vasp_gui.sym_prec,"SYMPREC: Ch. 6.27 DEFAULT 10^-5\nSets the accuracy of ion positions\nin determining the system symmetry."); VASP_ENTRY_TABLE(vasp_gui.poscar_a0,vasp_gui.calc.poscar_a0,"%.4lf","A0=",4,5,0,1); -VASP_TOOLTIP(vasp_gui.poscar_a0,"Lattice parameter (Ch. 5.7)\nSets the lattice constant (Ang.) parameter\nevery lattice vector will be scaled with."); +GUI_TOOLTIP(vasp_gui.poscar_a0,"Lattice parameter (Ch. 5.7)\nSets the lattice constant (Ang.) parameter\nevery lattice vector will be scaled with."); /* 2nd line */ /*empty: col0 (TODO: SUPERCELL)*/ VASP_CHECK_TABLE(vasp_gui.poscar_direct,vasp_gui.calc.poscar_direct,toggle_poscar_direct,"Direct Coord.",1,2,1,2); -VASP_TOOLTIP(vasp_gui.poscar_direct,"Sets whether ions positions are given\nin direct lattice or cartesian coordinate."); +GUI_TOOLTIP(vasp_gui.poscar_direct,"Sets whether ions positions are given\nin direct lattice or cartesian coordinate."); VASP_ENTRY_TABLE(vasp_gui.poscar_ux,vasp_gui.calc.poscar_ux,"%.4lf","UX=",2,3,1,2); -VASP_TOOLTIP(vasp_gui.poscar_ux,"First lattice vector x component."); +GUI_TOOLTIP(vasp_gui.poscar_ux,"First lattice vector x component."); VASP_ENTRY_TABLE(vasp_gui.poscar_uy,vasp_gui.calc.poscar_uy,"%.4lf","UY=",3,4,1,2); -VASP_TOOLTIP(vasp_gui.poscar_uy,"First lattice vector y component."); +GUI_TOOLTIP(vasp_gui.poscar_uy,"First lattice vector y component."); VASP_ENTRY_TABLE(vasp_gui.poscar_uz,vasp_gui.calc.poscar_uz,"%.4lf","UZ=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.poscar_uz,"First lattice vector z component."); +GUI_TOOLTIP(vasp_gui.poscar_uz,"First lattice vector z component."); /* 3rd line */ /*empty: col0 (TODO: -X)*/ /*empty: col1 (TODO: +X)*/ VASP_ENTRY_TABLE(vasp_gui.poscar_vx,vasp_gui.calc.poscar_vx,"%.4lf","VX=",2,3,2,3); -VASP_TOOLTIP(vasp_gui.poscar_vx,"Second lattice vector x component."); +GUI_TOOLTIP(vasp_gui.poscar_vx,"Second lattice vector x component."); VASP_ENTRY_TABLE(vasp_gui.poscar_vy,vasp_gui.calc.poscar_vy,"%.4lf","VY=",3,4,2,3); -VASP_TOOLTIP(vasp_gui.poscar_vy,"Second lattice vector y component."); +GUI_TOOLTIP(vasp_gui.poscar_vy,"Second lattice vector y component."); VASP_ENTRY_TABLE(vasp_gui.poscar_vz,vasp_gui.calc.poscar_vz,"%.4lf","VZ=",4,5,2,3); -VASP_TOOLTIP(vasp_gui.poscar_vz,"Second lattice vector z component."); +GUI_TOOLTIP(vasp_gui.poscar_vz,"Second lattice vector z component."); /* 4th line */ /*empty: col0 (TODO: -Y)*/ /*empty: col1 (TODO: +Y)*/ VASP_ENTRY_TABLE(vasp_gui.poscar_wx,vasp_gui.calc.poscar_wx,"%.4lf","WX=",2,3,3,4); -VASP_TOOLTIP(vasp_gui.poscar_wx,"Third lattice vector x component."); +GUI_TOOLTIP(vasp_gui.poscar_wx,"Third lattice vector x component."); VASP_ENTRY_TABLE(vasp_gui.poscar_wy,vasp_gui.calc.poscar_wy,"%.4lf","WY=",3,4,3,4); -VASP_TOOLTIP(vasp_gui.poscar_wy,"Third lattice vector y component."); +GUI_TOOLTIP(vasp_gui.poscar_wy,"Third lattice vector y component."); VASP_ENTRY_TABLE(vasp_gui.poscar_wz,vasp_gui.calc.poscar_wz,"%.4lf","WZ=",4,5,3,4); -VASP_TOOLTIP(vasp_gui.poscar_wz,"Third lattice vector z component."); +GUI_TOOLTIP(vasp_gui.poscar_wz,"Third lattice vector z component."); /* 5th line */ /*empty: col0 (TODO: -Z)*/ /*empty: col1 (TODO: +Z)*/ VASP_CHECK_TABLE(vasp_gui.poscar_tx,vasp_gui.calc.poscar_tx,NULL,"TX",2,3,4,5);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin first lattice coordinate."); +GUI_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin first lattice coordinate."); VASP_CHECK_TABLE(vasp_gui.poscar_ty,vasp_gui.calc.poscar_ty,NULL,"TY",3,4,4,5);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin second lattice coordinate."); +GUI_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin second lattice coordinate."); VASP_CHECK_TABLE(vasp_gui.poscar_tz,vasp_gui.calc.poscar_tz,NULL,"TZ",4,5,4,5);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin third lattice coordinate."); +GUI_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin third lattice coordinate."); /* 6th line */ /*this combo is special and should be explicitely defined*/ hbox = gtk_hbox_new(FALSE, 0); @@ -3466,7 +3467,7 @@ vasp_gui.calc.atoms_total=idx; gtk_box_pack_start(GTK_BOX(hbox),vasp_gui.poscar_atoms,TRUE,TRUE,0); gtk_table_attach_defaults(GTK_TABLE(table),hbox,0,4,5,6); g_signal_connect(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),"changed",GTK_SIGNAL_FUNC(vasp_poscar_atoms_selected),data); -VASP_TOOLTIP(vasp_gui.poscar_atoms,"Atoms positions in POSCAR format."); +GUI_TOOLTIP(vasp_gui.poscar_atoms,"Atoms positions in POSCAR format."); /*2 buttons*/ hbox = gtk_hbox_new(FALSE, 0); VASP_NEW_SEPARATOR(); @@ -3476,15 +3477,15 @@ VASP_TOOLTIP(vasp_gui.poscar_atoms,"Atoms positions in POSCAR format."); /* 7th line */ VASP_ENTRY_TABLE(vasp_gui.poscar_index,vasp_gui.calc.poscar_index,"%i","INDEX:",0,1,6,7); gtk_widget_set_sensitive(vasp_gui.poscar_index,FALSE);/*<- is changed only by selecting poscar_atoms*/ -VASP_TOOLTIP(vasp_gui.poscar_index,"Atom number (in POSCAR ORDER)."); +GUI_TOOLTIP(vasp_gui.poscar_index,"Atom number (in POSCAR ORDER)."); VASP_ENTRY_TABLE(vasp_gui.poscar_symbol,vasp_gui.calc.poscar_symbol,"%s","SYMBOL:",1,2,6,7); -VASP_TOOLTIP(vasp_gui.poscar_index,"Atom symbol (will correspond to POSCAR).\nChanging symbol will change index accordingly."); +GUI_TOOLTIP(vasp_gui.poscar_index,"Atom symbol (will correspond to POSCAR).\nChanging symbol will change index accordingly."); VASP_ENTRY_TABLE(vasp_gui.poscar_x,vasp_gui.calc.poscar_x,"%.6lf","X=",2,3,6,7); -VASP_TOOLTIP(vasp_gui.poscar_x,"atom component X: x in cartesian mode\nand first lattice coordinate in direct mode."); +GUI_TOOLTIP(vasp_gui.poscar_x,"atom component X: x in cartesian mode\nand first lattice coordinate in direct mode."); VASP_ENTRY_TABLE(vasp_gui.poscar_y,vasp_gui.calc.poscar_y,"%.6lf","Y=",3,4,6,7); -VASP_TOOLTIP(vasp_gui.poscar_y,"atom component Y: y in cartesian mode\nand second lattice coordinate in direct mode."); +GUI_TOOLTIP(vasp_gui.poscar_y,"atom component Y: y in cartesian mode\nand second lattice coordinate in direct mode."); VASP_ENTRY_TABLE(vasp_gui.poscar_z,vasp_gui.calc.poscar_z,"%.6lf","Z=",4,5,6,7); -VASP_TOOLTIP(vasp_gui.poscar_z,"atom component Z: z in cartesian mode\nand third lattice coordinate in direct mode."); +GUI_TOOLTIP(vasp_gui.poscar_z,"atom component Z: z in cartesian mode\nand third lattice coordinate in direct mode."); /* initialize sensitive widget*/ VASP_COMBOBOX_SETUP(vasp_gui.poscar_free,1,vasp_poscar_free_selected); if((vasp_gui.calc.poscar_free==VPF_FIXED)||(vasp_gui.calc.poscar_free==VPF_FREE)){ @@ -3521,11 +3522,11 @@ if((vasp_gui.calc.poscar_free==VPF_FIXED)||(vasp_gui.calc.poscar_free==VPF_FREE) gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ VASP_ENTRY_TABLE(vasp_gui.ismear_3,vasp_gui.calc.ismear,"%i","ISMEAR=",0,1,0,1); -VASP_TOOLTIP(vasp_gui.ismear_3,"ISMEAR: Ch. 6.38 DEFAULT: 1\nDetermine how the partial occupations are set.\nIt is advised to change it to ISMEAR=0\nfor semiconducting or insulating materials."); +GUI_TOOLTIP(vasp_gui.ismear_3,"ISMEAR: Ch. 6.38 DEFAULT: 1\nDetermine how the partial occupations are set.\nIt is advised to change it to ISMEAR=0\nfor semiconducting or insulating materials."); VASP_CHECK_TABLE(vasp_gui.kgamma_3,vasp_gui.calc.kgamma,NULL,"KGAMMA",1,2,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.kgamma_3,"KGAMMA: Ch. 6.4 DEFAULT: TRUE\nWhen KPOINTS file is not present KGAMMA\nindicate if the k-grid is centered around gamma point."); +GUI_TOOLTIP(vasp_gui.kgamma_3,"KGAMMA: Ch. 6.4 DEFAULT: TRUE\nWhen KPOINTS file is not present KGAMMA\nindicate if the k-grid is centered around gamma point."); VASP_ENTRY_TABLE(vasp_gui.kspacing_3,vasp_gui.calc.kspacing,"%.4f","KSPACING=",2,3,0,1); -VASP_TOOLTIP(vasp_gui.kspacing_3,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS file is not present KSPACING\nDetermine the smallest spacing between k-points (Ang^-1)."); +GUI_TOOLTIP(vasp_gui.kspacing_3,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS file is not present KSPACING\nDetermine the smallest spacing between k-points (Ang^-1)."); /*empty: col3*/ /*empty: col4*/ /* --- end frame */ @@ -3543,26 +3544,26 @@ VASP_TOOLTIP(vasp_gui.kspacing_3,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS f VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Gamma (M&P)"); VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Monkhorst-Pack classic"); VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Basis set definition"); -VASP_TOOLTIP(vasp_gui.kpoints_mode,"Sets how the k-points are generated/entered as defined in Ch. 5.5."); +GUI_TOOLTIP(vasp_gui.kpoints_mode,"Sets how the k-points are generated/entered as defined in Ch. 5.5."); VASP_CHECK_TABLE(vasp_gui.kpoints_cart,vasp_gui.calc.kpoints_cart,NULL,"Cartesian",1,2,0,1);/*not calling anything*/ -VASP_TOOLTIP(vasp_gui.kpoints_cart,"Switch cartesian/reciprocal lattice coordinate mode."); +GUI_TOOLTIP(vasp_gui.kpoints_cart,"Switch cartesian/reciprocal lattice coordinate mode."); VASP_SPIN_TABLE(vasp_gui.kpoints_kx,vasp_gui.calc.kpoints_kx,NULL,"KX",2,3,0,1); -VASP_TOOLTIP(vasp_gui.kpoints_kx,"Grid size for automated generation\n1st component only for M&P."); +GUI_TOOLTIP(vasp_gui.kpoints_kx,"Grid size for automated generation\n1st component only for M&P."); VASP_SPIN_TABLE(vasp_gui.kpoints_ky,vasp_gui.calc.kpoints_ky,NULL,"KY",3,4,0,1); -VASP_TOOLTIP(vasp_gui.kpoints_ky,"2nd Component of the M&P grid size."); +GUI_TOOLTIP(vasp_gui.kpoints_ky,"2nd Component of the M&P grid size."); VASP_SPIN_TABLE(vasp_gui.kpoints_kz,vasp_gui.calc.kpoints_kz,NULL,"KZ",4,5,0,1); -VASP_TOOLTIP(vasp_gui.kpoints_kz,"3rd Component of the M&P grid size."); +GUI_TOOLTIP(vasp_gui.kpoints_kz,"3rd Component of the M&P grid size."); /* 2nd line */ VASP_ENTRY_TABLE(vasp_gui.kpoints_nkpts,vasp_gui.calc.kpoints_nkpts,"%i","NKPTS=",0,1,1,2); -VASP_TOOLTIP(vasp_gui.kpoints_nkpts,"Total number of k-points (0 for automated methods)."); +GUI_TOOLTIP(vasp_gui.kpoints_nkpts,"Total number of k-points (0 for automated methods)."); VASP_CHECK_TABLE(vasp_gui.have_tetra,vasp_gui.calc.kpoints_tetra,toogle_tetra,"Tetrahedron",1,2,1,2); -VASP_TOOLTIP(vasp_gui.have_tetra,"Switch on the tetrahedron method for entering k-points.\nISMEAR must be set to -5 for this method!"); +GUI_TOOLTIP(vasp_gui.have_tetra,"Switch on the tetrahedron method for entering k-points.\nISMEAR must be set to -5 for this method!"); VASP_ENTRY_TABLE(vasp_gui.kpoints_sx,vasp_gui.calc.kpoints_sx,"%.4lf","SX=",2,3,1,2); -VASP_TOOLTIP(vasp_gui.kpoints_sx,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 1st reciprocal lattice component."); +GUI_TOOLTIP(vasp_gui.kpoints_sx,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 1st reciprocal lattice component."); VASP_ENTRY_TABLE(vasp_gui.kpoints_sy,vasp_gui.calc.kpoints_sy,"%.4lf","SY=",3,4,1,2); -VASP_TOOLTIP(vasp_gui.kpoints_sy,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 2nd reciprocal lattice component."); +GUI_TOOLTIP(vasp_gui.kpoints_sy,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 2nd reciprocal lattice component."); VASP_ENTRY_TABLE(vasp_gui.kpoints_sz,vasp_gui.calc.kpoints_sz,"%.4lf","SZ=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.kpoints_sz,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 3rd reciprocal lattice component."); +GUI_TOOLTIP(vasp_gui.kpoints_sz,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 3rd reciprocal lattice component."); /* --- end frame */ /* --- Coordinate */ vasp_gui.kpoints_coord = gtk_frame_new("Coordinate"); @@ -3573,7 +3574,7 @@ VASP_TOOLTIP(vasp_gui.kpoints_sz,"In case a grid is used to generate k-points\nT /* 1st line */ VASP_COMBOBOX_TABLE(vasp_gui.kpoints_kpts,"KPOINT:",0,4,0,1); VASP_COMBOBOX_ADD(vasp_gui.kpoints_kpts,"ADD kpoint"); -VASP_TOOLTIP(vasp_gui.kpoints_kpts,"List of the k-points coordinates.\nThe index after comment sign \"! kpoint:\" can be used\nfor entering tetrahedron edge definition."); +GUI_TOOLTIP(vasp_gui.kpoints_kpts,"List of the k-points coordinates.\nThe index after comment sign \"! kpoint:\" can be used\nfor entering tetrahedron edge definition."); /*2 buttons*/ hbox = gtk_hbox_new(FALSE, 0); VASP_NEW_SEPARATOR(); @@ -3583,15 +3584,15 @@ VASP_TOOLTIP(vasp_gui.kpoints_kpts,"List of the k-points coordinates.\nThe index /* 2nd line */ VASP_ENTRY_TABLE(vasp_gui.kpoints_i,vasp_gui.calc.kpoints_i,"%i","INDEX:",0,1,1,2); gtk_widget_set_sensitive(vasp_gui.kpoints_i,FALSE);/*<- is changed only by selecting kpoints_kpts*/ -VASP_TOOLTIP(vasp_gui.kpoints_i,"The index of current k-point.\n(can be changed by deletion/addition only)"); +GUI_TOOLTIP(vasp_gui.kpoints_i,"The index of current k-point.\n(can be changed by deletion/addition only)"); VASP_ENTRY_TABLE(vasp_gui.kpoints_x,vasp_gui.calc.kpoints_x,"%.4lf","X=",1,2,1,2); -VASP_TOOLTIP(vasp_gui.kpoints_x,"Coordinate of k-point in 1st component of selected mode.\n(cartesian or reciprocal)"); +GUI_TOOLTIP(vasp_gui.kpoints_x,"Coordinate of k-point in 1st component of selected mode.\n(cartesian or reciprocal)"); VASP_ENTRY_TABLE(vasp_gui.kpoints_y,vasp_gui.calc.kpoints_y,"%.4lf","Y=",2,3,1,2); -VASP_TOOLTIP(vasp_gui.kpoints_y,"Coordinate of k-point in 2nd component of selected mode.\n(cartesian or reciprocal)"); +GUI_TOOLTIP(vasp_gui.kpoints_y,"Coordinate of k-point in 2nd component of selected mode.\n(cartesian or reciprocal)"); VASP_ENTRY_TABLE(vasp_gui.kpoints_z,vasp_gui.calc.kpoints_z,"%.4lf","Z=",3,4,1,2); -VASP_TOOLTIP(vasp_gui.kpoints_z,"Coordinate of k-point in 3rd component of selected mode.\n(cartesian or reciprocal)"); +GUI_TOOLTIP(vasp_gui.kpoints_z,"Coordinate of k-point in 3rd component of selected mode.\n(cartesian or reciprocal)"); VASP_ENTRY_TABLE(vasp_gui.kpoints_w,vasp_gui.calc.kpoints_w,"%.4lf","W=",4,5,1,2); -VASP_TOOLTIP(vasp_gui.kpoints_w,"Symmetry degeneration weight of k-point.\nSum of all weight does not have to be 1\nbut relative ratio should be respected."); +GUI_TOOLTIP(vasp_gui.kpoints_w,"Symmetry degeneration weight of k-point.\nSum of all weight does not have to be 1\nbut relative ratio should be respected."); /* --- end frame */ /* --- Tetrahedron */ vasp_gui.kpoints_tetra = gtk_frame_new("Tetrahedron"); @@ -3601,17 +3602,17 @@ VASP_TOOLTIP(vasp_gui.kpoints_w,"Symmetry degeneration weight of k-point.\nSum o gtk_container_add(GTK_CONTAINER(vasp_gui.kpoints_tetra), table); /* 1st line */ VASP_ENTRY_TABLE(vasp_gui.tetra_total,vasp_gui.calc.tetra_total,"%i","TOTAL=",0,1,0,1); -VASP_TOOLTIP(vasp_gui.tetra_total,"Total number of tetrahedrons."); +GUI_TOOLTIP(vasp_gui.tetra_total,"Total number of tetrahedrons."); label = gtk_label_new("EXACT VOLUME:"); gtk_table_attach_defaults(GTK_TABLE(table),label,1,2,0,1); VASP_ENTRY_TABLE(vasp_gui.tetra_volume,vasp_gui.calc.tetra_volume,"%.6lf","V=",2,3,0,1); -VASP_TOOLTIP(vasp_gui.tetra_volume,"Volume weight for a single tetrahedron.\nAll have a volume defined by the ratio of\ntetrahedron volume / Brillouin zone Volume."); +GUI_TOOLTIP(vasp_gui.tetra_volume,"Volume weight for a single tetrahedron.\nAll have a volume defined by the ratio of\ntetrahedron volume / Brillouin zone Volume."); label = gtk_label_new("for (A,B,C,D) tetrahedron"); gtk_table_attach_defaults(GTK_TABLE(table),label,3,6,0,1); /* 2nd line */ VASP_COMBOBOX_TABLE(vasp_gui.tetra,"TETRAHEDRON:",0,5,1,2); VASP_COMBOBOX_ADD(vasp_gui.tetra,"ADD tetrahedron"); -VASP_TOOLTIP(vasp_gui.tetra,"Tetrahedron list, consisting of\nsymmetry degeneration weight followed by\nfour corner points of each tetrahedron\nin k-point indices given above."); +GUI_TOOLTIP(vasp_gui.tetra,"Tetrahedron list, consisting of\nsymmetry degeneration weight followed by\nfour corner points of each tetrahedron\nin k-point indices given above."); /*2 buttons*/ hbox = gtk_hbox_new(FALSE, 0); VASP_NEW_SEPARATOR(); @@ -3621,17 +3622,17 @@ VASP_TOOLTIP(vasp_gui.tetra,"Tetrahedron list, consisting of\nsymmetry degenerat /* 3rd line */ VASP_ENTRY_TABLE(vasp_gui.tetra_i,vasp_gui.calc.tetra_i,"%i","INDEX:",0,1,2,3); gtk_widget_set_sensitive(vasp_gui.tetra_i,FALSE);/*<- is changed only by selecting tetra*/ -VASP_TOOLTIP(vasp_gui.tetra_i,"The index of current tetrahedron.\n(can be changed by deletion/addition only)"); +GUI_TOOLTIP(vasp_gui.tetra_i,"The index of current tetrahedron.\n(can be changed by deletion/addition only)"); VASP_ENTRY_TABLE(vasp_gui.tetra_w,vasp_gui.calc.tetra_w,"%.4lf","Degen. W=",1,2,2,3); -VASP_TOOLTIP(vasp_gui.tetra_w,"Symmetry degeneration weight.\nUnlike k-points, weight must be normalized\nie. total Brillouin zone Volume should be recovered\nby summing all degeneration * V"); +GUI_TOOLTIP(vasp_gui.tetra_w,"Symmetry degeneration weight.\nUnlike k-points, weight must be normalized\nie. total Brillouin zone Volume should be recovered\nby summing all degeneration * V"); VASP_ENTRY_TABLE(vasp_gui.tetra_a,vasp_gui.calc.tetra_a,"%i","PtA:",2,3,2,3); -VASP_TOOLTIP(vasp_gui.tetra_a,"1st corner of the tetrahedron (A) in k-point index."); +GUI_TOOLTIP(vasp_gui.tetra_a,"1st corner of the tetrahedron (A) in k-point index."); VASP_ENTRY_TABLE(vasp_gui.tetra_b,vasp_gui.calc.tetra_b,"%i","PtB:",3,4,2,3); -VASP_TOOLTIP(vasp_gui.tetra_b,"2nd corner of the tetrahedron (B) in k-point index."); +GUI_TOOLTIP(vasp_gui.tetra_b,"2nd corner of the tetrahedron (B) in k-point index."); VASP_ENTRY_TABLE(vasp_gui.tetra_c,vasp_gui.calc.tetra_c,"%i","PtC:",4,5,2,3); -VASP_TOOLTIP(vasp_gui.tetra_c,"3rd corner of the tetrahedron (C) in k-point index."); +GUI_TOOLTIP(vasp_gui.tetra_c,"3rd corner of the tetrahedron (C) in k-point index."); VASP_ENTRY_TABLE(vasp_gui.tetra_d,vasp_gui.calc.tetra_d,"%i","PtD:",5,6,2,3); -VASP_TOOLTIP(vasp_gui.tetra_d,"4th corner of the tetrahedron (D) in k-point index."); +GUI_TOOLTIP(vasp_gui.tetra_d,"4th corner of the tetrahedron (D) in k-point index."); /* initialize */ g_signal_connect(GTK_OBJECT(GTK_ENTRY(vasp_gui.ismear_3)),"changed",GTK_SIGNAL_FUNC(ismear_changed),data); g_signal_connect(GTK_OBJECT(GTK_ENTRY(vasp_gui.kspacing_3)),"changed",GTK_SIGNAL_FUNC(kspacing_changed),data); @@ -3657,7 +3658,7 @@ VASP_TOOLTIP(vasp_gui.tetra_d,"4th corner of the tetrahedron (D) in k-point inde /* 1st line */ VASP_TEXT_TABLE(vasp_gui.poscar_species,vasp_gui.calc.species_symbols,"SPECIES:",0,1,0,1); gtk_widget_set_sensitive(vasp_gui.poscar_species,FALSE); -VASP_TOOLTIP(vasp_gui.poscar_species,"List of atomic symbol of the species\ndetected in the POSCAR ionic information."); +GUI_TOOLTIP(vasp_gui.poscar_species,"List of atomic symbol of the species\ndetected in the POSCAR ionic information."); /* 2nd line */ label = gtk_label_new("(each species will require a separate POTCAR information)"); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2); @@ -3675,19 +3676,19 @@ VASP_TOOLTIP(vasp_gui.poscar_species,"List of atomic symbol of the species\ndete vasp_gui.potcar_select_file = add_radio_button("Use POTCAR file",(gpointer)toggle_potcar_file,NULL); vasp_gui.potcar_select_folder = add_radio_button("Use POTCAR path",(gpointer)toggle_potcar_folder,NULL); gtk_table_attach_defaults(GTK_TABLE(table),vbox,0,1,0,2); -VASP_TOOLTIP(vasp_gui.potcar_select_file,"Load a previously prepared POTCAR file.\nThe species (and species order) should match\nEXACTLY those of the POSCAR ion information."); -VASP_TOOLTIP(vasp_gui.potcar_select_folder,"Use the directory where all POTCAR information are available.\nUsually a directory containing atomic symbols sub-directories."); +GUI_TOOLTIP(vasp_gui.potcar_select_file,"Load a previously prepared POTCAR file.\nThe species (and species order) should match\nEXACTLY those of the POSCAR ion information."); +GUI_TOOLTIP(vasp_gui.potcar_select_folder,"Use the directory where all POTCAR information are available.\nUsually a directory containing atomic symbols sub-directories."); VASP_TEXT_TABLE(vasp_gui.potcar_file,vasp_gui.calc.potcar_file,"FILE:",1,3,0,1); VASP_BUTTON_TABLE(vasp_gui.potcar_file_button,GTK_STOCK_OPEN,load_potcar_file_dialog,3,4,0,1); -VASP_TOOLTIP(vasp_gui.potcar_file,"POTCAR file, including its full path."); +GUI_TOOLTIP(vasp_gui.potcar_file,"POTCAR file, including its full path."); /* 2nd line */ VASP_TEXT_TABLE(vasp_gui.potcar_folder,vasp_gui.calc.potcar_folder,"PATH:",1,3,1,2); VASP_BUTTON_TABLE(vasp_gui.potcar_folder_button,GTK_STOCK_OPEN,load_potcar_folder_dialog,3,4,1,2); -VASP_TOOLTIP(vasp_gui.potcar_folder,"Full PATH to the POTCAR sub-directories."); +GUI_TOOLTIP(vasp_gui.potcar_folder,"Full PATH to the POTCAR sub-directories."); /* 3rd line */ VASP_COMBOBOX_TABLE(vasp_gui.species_flavor,"FLAVOR:",2,3,2,3); VASP_BUTTON_TABLE(vasp_gui.species_button,GTK_STOCK_APPLY,apply_species_flavor,3,4,2,3); -VASP_TOOLTIP(vasp_gui.species_flavor,"When Using PATH method, for each species a choice\nbetween different pseudopotential setting (flavors) exists\nEx: _h hard, _s soft _pv include pseudo-core valence, etc."); +GUI_TOOLTIP(vasp_gui.species_flavor,"When Using PATH method, for each species a choice\nbetween different pseudopotential setting (flavors) exists\nEx: _h hard, _s soft _pv include pseudo-core valence, etc."); /* initialize */ toggle_potcar_file(NULL,NULL); /* --- end frame */ @@ -3702,12 +3703,12 @@ VASP_TOOLTIP(vasp_gui.species_flavor,"When Using PATH method, for each species a label = gtk_label_new("DETECTED"); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,2); VASP_TEXT_TABLE(vasp_gui.potcar_species,vasp_gui.calc.potcar_species,"SPECIES:",1,2,0,1); -VASP_TOOLTIP(vasp_gui.potcar_species,"List of atomic symbol of the species\ndetected from the POTCAR setting."); +GUI_TOOLTIP(vasp_gui.potcar_species,"List of atomic symbol of the species\ndetected from the POTCAR setting."); gtk_widget_set_sensitive(vasp_gui.potcar_species,FALSE); /* 2nd line */ /*occ: col0*/ VASP_TEXT_TABLE(vasp_gui.potcar_species_flavor,vasp_gui.calc.potcar_species_flavor,"FLAVOR:",1,2,1,2); -VASP_TOOLTIP(vasp_gui.potcar_species_flavor,"List of the pseudopotential flavors (PATH method)\ndetected from the POTCAR setting."); +GUI_TOOLTIP(vasp_gui.potcar_species_flavor,"List of the pseudopotential flavors (PATH method)\ndetected from the POTCAR setting."); gtk_widget_set_sensitive(vasp_gui.potcar_species_flavor,FALSE); /*----------------*/ @@ -3725,25 +3726,25 @@ VASP_TOOLTIP(vasp_gui.potcar_species_flavor,"List of the pseudopotential flavors /* 1st line */ VASP_LABEL_TABLE("VASP EXEC:",0,1,0,1); VASP_TEXT_TABLE(vasp_gui.job_vasp_exe,vasp_gui.calc.job_vasp_exe,"FILE=",1,5,0,1); -VASP_TOOLTIP(vasp_gui.job_vasp_exe,"Location (full path) of the vasp executable."); +GUI_TOOLTIP(vasp_gui.job_vasp_exe,"Location (full path) of the vasp executable."); VASP_BUTTON_TABLE(button,GTK_STOCK_OPEN,load_vasp_exe_dialog,5,6,0,1); /* 2nd line */ VASP_LABEL_TABLE("CALCUL PATH:",0,1,1,2); VASP_TEXT_TABLE(vasp_gui.job_path,vasp_gui.calc.job_path,"PATH=",1,5,1,2); -VASP_TOOLTIP(vasp_gui.job_path,"Location (full path) of the calculation directory.\nit is IMPORTANT to check this parameter so that\n* no other calculation is overwritten\n* calculation will not start in an unexpected directory."); +GUI_TOOLTIP(vasp_gui.job_path,"Location (full path) of the calculation directory.\nit is IMPORTANT to check this parameter so that\n* no other calculation is overwritten\n* calculation will not start in an unexpected directory."); VASP_BUTTON_TABLE(button,GTK_STOCK_OPEN,load_path_dialog,5,6,1,2); /* 3rd line */ VASP_LABEL_TABLE("OUTPUT:",0,1,2,3); VASP_CHECK_TABLE(button,vasp_gui.calc.lwave,NULL,"LWAVE",1,2,2,3);/*not calling anything*/ -VASP_TOOLTIP(button,"LWAVE: Ch. 6.52 DEFAULT: TRUE\nIf set the WAVECAR (wavefunctions) file is written."); +GUI_TOOLTIP(button,"LWAVE: Ch. 6.52 DEFAULT: TRUE\nIf set the WAVECAR (wavefunctions) file is written."); VASP_CHECK_TABLE(button,vasp_gui.calc.lcharg,NULL,"LCHARG",2,3,2,3);/*not calling anything*/ -VASP_TOOLTIP(button,"LCHARG: Ch. 6.52 DEFAULT: TRUE\nIf set the CHGCAR (charge density) file is written."); +GUI_TOOLTIP(button,"LCHARG: Ch. 6.52 DEFAULT: TRUE\nIf set the CHGCAR (charge density) file is written."); VASP_CHECK_TABLE(button,vasp_gui.calc.lvtot,NULL,"LVTOT",3,4,2,3);/*not calling anything*/ -VASP_TOOLTIP(button,"LVTOT: Ch. 6.53 DEFAULT: FALSE\nIf set the LOCPOT (local potential) file is written."); +GUI_TOOLTIP(button,"LVTOT: Ch. 6.53 DEFAULT: FALSE\nIf set the LOCPOT (local potential) file is written."); VASP_CHECK_TABLE(button,vasp_gui.calc.lvhar,NULL,"LVHAR",4,5,2,3);/*not calling anything*/ -VASP_TOOLTIP(button,"LVHAR: Ch. 6.54 DEFAULT: FALSE\nIf set the full local potential is written to LOCPOT\n(ie. ionic+Hartree+XC) otherwise only electrostatic\n(ie. ionic+Hartree) is written."); +GUI_TOOLTIP(button,"LVHAR: Ch. 6.54 DEFAULT: FALSE\nIf set the full local potential is written to LOCPOT\n(ie. ionic+Hartree+XC) otherwise only electrostatic\n(ie. ionic+Hartree) is written."); VASP_CHECK_TABLE(button,vasp_gui.calc.lelf,NULL,"LELF",5,6,2,3);/*not calling anything*/ -VASP_TOOLTIP(button,"LELF: Ch 6.55 DEFAULT: FALSE\nIf set the ELFCAR (electron localization function)\nfile is written."); +GUI_TOOLTIP(button,"LELF: Ch 6.55 DEFAULT: FALSE\nIf set the ELFCAR (electron localization function)\nfile is written."); /* --- end frame */ /* --- PARALLEL */ frame = gtk_frame_new("Parallel Optimization"); @@ -3754,21 +3755,21 @@ VASP_TOOLTIP(button,"LELF: Ch 6.55 DEFAULT: FALSE\nIf set the ELFCAR (electron l /* 1st line */ VASP_LABEL_TABLE("MPIRUN:",0,1,0,1); VASP_TEXT_TABLE(vasp_gui.job_mpirun,vasp_gui.calc.job_mpirun,"FILE=",1,5,0,1); -VASP_TOOLTIP(vasp_gui.job_mpirun,"Location (full path) of mpirun executable.\nRequired for parallel calculation only."); +GUI_TOOLTIP(vasp_gui.job_mpirun,"Location (full path) of mpirun executable.\nRequired for parallel calculation only."); VASP_BUTTON_TABLE(button,GTK_STOCK_OPEN,load_mpirun_dialog,5,6,0,1); /* 2nd line */ VASP_SPIN_TABLE(vasp_gui.job_nproc,vasp_gui.calc.job_nproc,parallel_eq,"NP=",0,1,1,2); -VASP_TOOLTIP(vasp_gui.job_nproc,"Total number of CPU used for calculation.\nwill be used as N in \"mpirun -np N vasp\"\nto start vasp calculation."); +GUI_TOOLTIP(vasp_gui.job_nproc,"Total number of CPU used for calculation.\nwill be used as N in \"mpirun -np N vasp\"\nto start vasp calculation."); VASP_SPIN_TABLE(vasp_gui.ncore,vasp_gui.calc.ncore,parallel_eq,"NCORE=",1,2,1,2); -VASP_TOOLTIP(vasp_gui.ncore,"NCORE: Ch. 6.57 DEFAULT: 1\nSets how many cores works on one orbital.\nNote that NCORE is limited by KPAR."); +GUI_TOOLTIP(vasp_gui.ncore,"NCORE: Ch. 6.57 DEFAULT: 1\nSets how many cores works on one orbital.\nNote that NCORE is limited by KPAR."); VASP_SPIN_TABLE(vasp_gui.kpar,vasp_gui.calc.kpar,parallel_eq,"KPAR=",2,3,1,2); -VASP_TOOLTIP(vasp_gui.kpar,"KPAR: Ch. 6.57 DEFAULT: 1\nSets the number of k-points treated in parallel.\nEach k-point is worked on by NCORE CPUs."); +GUI_TOOLTIP(vasp_gui.kpar,"KPAR: Ch. 6.57 DEFAULT: 1\nSets the number of k-points treated in parallel.\nEach k-point is worked on by NCORE CPUs."); VASP_CHECK_TABLE(button,vasp_gui.calc.lplane,NULL,"LPLANE",3,4,1,2);/*not calling anything*/ -VASP_TOOLTIP(button,"LPLANE: Ch. 6.57 DEFAULT: TRUE\nIf set the real-space data distribution is done plane wise."); +GUI_TOOLTIP(button,"LPLANE: Ch. 6.57 DEFAULT: TRUE\nIf set the real-space data distribution is done plane wise."); VASP_CHECK_TABLE(button,vasp_gui.calc.lscalu,NULL,"LSCALU",4,5,1,2);/*not calling anything*/ -VASP_TOOLTIP(button,"LSCALU: Ch. 6.59 DEFAULT: FALSE\nIf set parallel LU decomposition will be used."); +GUI_TOOLTIP(button,"LSCALU: Ch. 6.59 DEFAULT: FALSE\nIf set parallel LU decomposition will be used."); VASP_CHECK_TABLE(button,vasp_gui.calc.lscalapack,NULL,"LSCALAPACK",5,6,1,2);/*not calling anything*/ -VASP_TOOLTIP(button,"LSCALAPACK: Ch. 6.59 DEFAULT: FALSE\nIf set scaLAPACK routines will be used."); +GUI_TOOLTIP(button,"LSCALAPACK: Ch. 6.59 DEFAULT: FALSE\nIf set scaLAPACK routines will be used."); /* --- end frame */ /* --- DISTANT */ frame = gtk_frame_new("Distant calculation"); diff --git a/src/project.c b/src/project.c index 5b94211..8addfcc 100644 --- a/src/project.c +++ b/src/project.c @@ -293,6 +293,9 @@ fullname = g_build_filename(sysenv.cwd, filename, NULL); model_init(&temp_model); temp_model.grafted = TRUE; +grid[0]=0; +grid[1]=0; + /* CURRENT */ project = project_new("solvent"); project_model_add(model, project); From 0c70d5cebcb776ee241f77a79700a1687671096d Mon Sep 17 00:00:00 2001 From: ovhpa Date: Tue, 24 Jul 2018 19:37:38 +0900 Subject: [PATCH 02/56] gui_uspex: prepare unified gui interface II. --- src/gui_vasp.c | 196 ++++++++++++++++++++++++------------------------- 1 file changed, 98 insertions(+), 98 deletions(-) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index e106e77..4d68006 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -2868,85 +2868,85 @@ GUI_TOOLTIP(vasp_gui.simple_apply,"Use this to obtain a preset of setting.\nIf c table = gtk_table_new(5, 4, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.prec,"PREC=",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.prec,"Normal"); - VASP_COMBOBOX_ADD(vasp_gui.prec,"Single"); - VASP_COMBOBOX_ADD(vasp_gui.prec,"Accurate"); - VASP_COMBOBOX_ADD(vasp_gui.prec,"High"); - VASP_COMBOBOX_ADD(vasp_gui.prec,"Medium"); - VASP_COMBOBOX_ADD(vasp_gui.prec,"Low"); + GUI_COMBOBOX_TABLE(table,vasp_gui.prec,"PREC=",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.prec,"Normal"); + GUI_COMBOBOX_ADD(vasp_gui.prec,"Single"); + GUI_COMBOBOX_ADD(vasp_gui.prec,"Accurate"); + GUI_COMBOBOX_ADD(vasp_gui.prec,"High"); + GUI_COMBOBOX_ADD(vasp_gui.prec,"Medium"); + GUI_COMBOBOX_ADD(vasp_gui.prec,"Low"); GUI_TOOLTIP(vasp_gui.prec,"PREC: Ch. 6.11 DEFAULT: Normal\nSets numerical accuracy by changing\nENCUT, NG{X,Y,Z}, NG{X,Y,Z}F, and ROPT.\n(can be override manually)"); - VASP_CHECK_TABLE(button,vasp_gui.calc.use_prec,prec_toggle,"USE PREC",1,2,0,1); + GUI_CHECK_TABLE(table,button,vasp_gui.calc.use_prec,prec_toggle,"USE PREC",1,2,0,1); GUI_TOOLTIP(button,"Let PREC decides on ENCUT, NG{X,Y,Z}, NG{X,Y,Z}F, and ROPT."); - VASP_ENTRY_TABLE(vasp_gui.encut,vasp_gui.calc.encut,"%.2lf","ENCUT=",2,3,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.encut,vasp_gui.calc.encut,"%.2lf","ENCUT=",2,3,0,1); GUI_TOOLTIP(vasp_gui.encut,"ENCUT: Ch. 6.9 DEFAULT: MAX(ENMAX)\nPlane-wave basis cutoff energy (eV).\nDefault MAX(ENMAX) is taken from POTCAR file."); - VASP_ENTRY_TABLE(vasp_gui.enaug,vasp_gui.calc.enaug,"%.2lf","ENAUG=",3,4,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.enaug,vasp_gui.calc.enaug,"%.2lf","ENAUG=",3,4,0,1); GUI_TOOLTIP(vasp_gui.enaug,"ENAUG: Ch. 6.10 DEFAULT: EAUG\nKinetic cutoff for augmentation charges.\nDefault EAUG is taken from POTCAR file."); - VASP_ENTRY_TABLE(vasp_gui.ediff,vasp_gui.calc.ediff,"%.2lE","EDIFF=",4,5,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.ediff,vasp_gui.calc.ediff,"%.2lE","EDIFF=",4,5,0,1); GUI_TOOLTIP(vasp_gui.ediff,"EDIFF: Ch. 6.18 DEFAULT: 10^{-4}\nSet the criterion (eV) for electronic convergence."); /* 2nd line */ - VASP_COMBOBOX_TABLE(vasp_gui.algo,"ALGO=",0,1,1,2); - VASP_COMBOBOX_ADD(vasp_gui.algo,"NORMAL"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"USE_IALGO"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"VERYFAST"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"FAST"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"CONJUGATE"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"ALL"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"DAMPED"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"SUBROT"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"EIGENVAL"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"NONE"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"NOTHING"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"EXACT"); - VASP_COMBOBOX_ADD(vasp_gui.algo,"DIAG"); + GUI_COMBOBOX_TABLE(table,vasp_gui.algo,"ALGO=",0,1,1,2); + GUI_COMBOBOX_ADD(vasp_gui.algo,"NORMAL"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"USE_IALGO"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"VERYFAST"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"FAST"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"CONJUGATE"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"ALL"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"DAMPED"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"SUBROT"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"EIGENVAL"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"NONE"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"NOTHING"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"EXACT"); + GUI_COMBOBOX_ADD(vasp_gui.algo,"DIAG"); GUI_TOOLTIP(vasp_gui.algo,"ALGO: Ch. 6.46 DEFAULT: Normal\nSelect the electronic minimization algorithm.\nIt is overrided by IALGO when specified."); - VASP_CHECK_TABLE(button,vasp_gui.calc.ldiag,NULL,"LDIAG",1,2,1,2);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.ldiag,NULL,"LDIAG",1,2,1,2);/*not calling anything*/ GUI_TOOLTIP(button,"LDIAG: Ch. 6.47 DEFAULT: TRUE\nSwitch on the sub-space rotation."); - VASP_ENTRY_TABLE(vasp_gui.nsim,vasp_gui.calc.nsim,"%i","NSIM=",2,3,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.nsim,vasp_gui.calc.nsim,"%i","NSIM=",2,3,1,2); GUI_TOOLTIP(vasp_gui.nsim,"NSIM: Ch. 6.48 DEFAULT: 4\nNumber of bands optimized at a time\nin blocked minimization algorithm."); - VASP_ENTRY_TABLE(vasp_gui.vtime,vasp_gui.calc.vtime,"%.4lf","TIME=",3,4,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.vtime,vasp_gui.calc.vtime,"%.4lf","TIME=",3,4,1,2); GUI_TOOLTIP(vasp_gui.vtime,"TIME: Ch. 6.51 DEFAULT: 0.4\nSelect the trial time or value step\nfor minimization algorithm IALGO=5X."); - VASP_ENTRY_TABLE(vasp_gui.iwavpr,vasp_gui.calc.iwavpr,"%i","IWAVPR=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.iwavpr,vasp_gui.calc.iwavpr,"%i","IWAVPR=",4,5,1,2); GUI_TOOLTIP(vasp_gui.iwavpr,"IWAVPR: Ch. 6.26 DEFAULT: 2(IBRION=0-2)\nDetermine how charge density/orbitals are predicted\nfrom one ionic configuration to the next.\nDefault is 0 if IBRION is different from 0-2."); /* 3rd line */ - VASP_COMBOBOX_TABLE(vasp_gui.ialgo,"IALGO=",0,1,2,3); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"2:FIXED ORB/1E"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"3:FIXED ORB"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"4:SUBROT ONLY"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"5:STEEPEST"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"6:CONJUGUATE GRADIENTS"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"7:PRECOND. STEEPEST"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"8:PRECOND. CG"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"38:KOSUGI"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"44:RMM STEEPEST"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"46:RMM PRECOND."); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"48:PRECOND. RMM"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"53:VAR DAMPED MD"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"54:VAR DAMPED QUENCH MD"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"58:VAR PRECOND. CG"); - VASP_COMBOBOX_ADD(vasp_gui.ialgo,"90:EXACT"); + GUI_COMBOBOX_TABLE(table,vasp_gui.ialgo,"IALGO=",0,1,2,3); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"2:FIXED ORB/1E"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"3:FIXED ORB"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"4:SUBROT ONLY"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"5:STEEPEST"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"6:CONJUGUATE GRADIENTS"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"7:PRECOND. STEEPEST"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"8:PRECOND. CG"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"38:KOSUGI"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"44:RMM STEEPEST"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"46:RMM PRECOND."); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"48:PRECOND. RMM"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"53:VAR DAMPED MD"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"54:VAR DAMPED QUENCH MD"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"58:VAR PRECOND. CG"); + GUI_COMBOBOX_ADD(vasp_gui.ialgo,"90:EXACT"); GUI_TOOLTIP(vasp_gui.ialgo,"IALGO: Ch. 6.47 DEFAULT: 38\nSets the minimization algorithm number.\nIt is advised to use ALGO instead of IALGO\ndue to instabilities in extra IALGO algorithms."); - VASP_CHECK_TABLE(button,vasp_gui.calc.auto_elec,elec_toggle,"AUTO",1,2,2,3); + GUI_CHECK_TABLE(table,button,vasp_gui.calc.auto_elec,elec_toggle,"AUTO",1,2,2,3); GUI_TOOLTIP(button,"Automatically sets NSIM, TIME, IWAVPR, NBANDS, and NELECT"); - VASP_ENTRY_TABLE(vasp_gui.nbands,vasp_gui.calc.nbands,"%i","NBANDS=",2,3,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.nbands,vasp_gui.calc.nbands,"%i","NBANDS=",2,3,2,3); GUI_TOOLTIP(vasp_gui.nbands,"NBANDS: Ch. 6.5 DEFAULT: NELEC/2+NIONS/2\nNumber of bands in the calculation.\nDefault for spin-polarized calcualtions is 0.6*NELECT+NMAG"); - VASP_ENTRY_TABLE(vasp_gui.nelect,vasp_gui.calc.nelect,"%.2lf","NELECT=",3,4,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.nelect,vasp_gui.calc.nelect,"%.2lf","NELECT=",3,4,2,3); GUI_TOOLTIP(vasp_gui.nelect,"NELECT: Ch. 6.35 DEFAULT: Ne valence\nSets the number of electrons\nCan be use add an extra charge background\nas an homogeneous background-charge."); /*empty: col4*/ /* 4th line */ /*empty: col0*/ - VASP_CHECK_TABLE(button,vasp_gui.calc.iniwav,NULL,"INIWAV",1,2,3,4);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.iniwav,NULL,"INIWAV",1,2,3,4);/*not calling anything*/ GUI_TOOLTIP(button,"INIWAV: Ch. 6.16 DEFAULT: 1\nDetermine how initial wavefunctions are filled\nThe only option is the default random filling.\nOther option (INIWAV=0) is usually not available."); - VASP_ENTRY_TABLE(vasp_gui.istart,vasp_gui.calc.istart,"%i","ISTART=",2,3,3,4); + GUI_ENTRY_TABLE(table,vasp_gui.istart,vasp_gui.calc.istart,"%i","ISTART=",2,3,3,4); GUI_TOOLTIP(vasp_gui.istart,"ISTART: Ch. 6.14 DEFAULT 1\nDetermine whether WAVECAR should be read.\nDefault is 0 when no WAVECAR file is found."); - VASP_ENTRY_TABLE(vasp_gui.icharg,vasp_gui.calc.icharg,"%i","ICHARG=",3,4,3,4); + GUI_ENTRY_TABLE(table,vasp_gui.icharg,vasp_gui.calc.icharg,"%i","ICHARG=",3,4,3,4); GUI_TOOLTIP(vasp_gui.icharg,"ICHARG: Ch. 6.15 DEFAULT 2\nDetermine how the initial charge density is calculated\nDefault is 0 if ISTART is not 0."); /*empty: col4*/ /* initialize */ - VASP_COMBOBOX_SETUP(vasp_gui.prec,0,vasp_prec_selected); - VASP_COMBOBOX_SETUP(vasp_gui.algo,0,vasp_algo_selected); - VASP_COMBOBOX_SETUP(vasp_gui.ialgo,7,vasp_ialgo_selected); - gtk_widget_set_sensitive(vasp_gui.ialgo,FALSE); + GUI_COMBOBOX_SETUP(vasp_gui.prec,0,vasp_prec_selected); + GUI_COMBOBOX_SETUP(vasp_gui.algo,0,vasp_algo_selected); + GUI_COMBOBOX_SETUP(vasp_gui.ialgo,7,vasp_ialgo_selected); + GUI_LOCK(vasp_gui.ialgo); prec_toggle(NULL,NULL); elec_toggle(NULL,NULL); /* --- end frame */ @@ -2957,50 +2957,50 @@ GUI_TOOLTIP(vasp_gui.icharg,"ICHARG: Ch. 6.15 DEFAULT 2\nDetermine how the initi table = gtk_table_new(5, 3, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.mixer,"IMIX=",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.mixer,"0:NONE"); - VASP_COMBOBOX_ADD(vasp_gui.mixer,"1:KERKER"); - VASP_COMBOBOX_ADD(vasp_gui.mixer,"2:TCHEBYCHEV"); - VASP_COMBOBOX_ADD(vasp_gui.mixer,"4:BROYDEN"); + GUI_COMBOBOX_TABLE(table,vasp_gui.mixer,"IMIX=",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.mixer,"0:NONE"); + GUI_COMBOBOX_ADD(vasp_gui.mixer,"1:KERKER"); + GUI_COMBOBOX_ADD(vasp_gui.mixer,"2:TCHEBYCHEV"); + GUI_COMBOBOX_ADD(vasp_gui.mixer,"4:BROYDEN"); GUI_TOOLTIP(vasp_gui.mixer,"IMIX: Ch. 6.49 DEFAULT: 4\nDetermine the type of mixing."); - VASP_CHECK_TABLE(button,vasp_gui.calc.auto_mixer,mixer_toggle,"AUTO MIXER",1,2,0,1); + GUI_CHECK_TABLE(table,button,vasp_gui.calc.auto_mixer,mixer_toggle,"AUTO MIXER",1,2,0,1); GUI_TOOLTIP(button,"Use automatic mixing settings."); - VASP_ENTRY_TABLE(vasp_gui.nelm,vasp_gui.calc.nelm,"%i","NELM=",2,3,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.nelm,vasp_gui.calc.nelm,"%i","NELM=",2,3,0,1); GUI_TOOLTIP(vasp_gui.nelm,"NELM: Ch. 6.17 DEFAULT: 60\nMaximum number of electronic steps."); - VASP_ENTRY_TABLE(vasp_gui.nelmdl,vasp_gui.calc.nelmdl,"%i","NELMDL=",3,4,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.nelmdl,vasp_gui.calc.nelmdl,"%i","NELMDL=",3,4,0,1); GUI_TOOLTIP(vasp_gui.nelmdl,"NELMDL: Ch. 6.17 DEFAULT -5(if IALGO=x8)\nSets the number of initial non-selfconsistent steps\ndefault is 0 if ISTART is not 0."); - VASP_ENTRY_TABLE(vasp_gui.nelmin,vasp_gui.calc.nelmin,"%i","NELMIN=",4,5,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.nelmin,vasp_gui.calc.nelmin,"%i","NELMIN=",4,5,0,1); GUI_TOOLTIP(vasp_gui.nelmin,"NELMIN: Ch. 6.17 DEFAULT: 2\nMinimum number of electronic steps."); /* 2nd line */ - VASP_COMBOBOX_TABLE(vasp_gui.mixpre,"MIXPRE=",0,1,1,2); - VASP_COMBOBOX_ADD(vasp_gui.mixpre,"0:NONE"); - VASP_COMBOBOX_ADD(vasp_gui.mixpre,"1:F=20 INVERSE KERKER"); - VASP_COMBOBOX_ADD(vasp_gui.mixpre,"2:F=200 INVERSE KERKER"); + GUI_COMBOBOX_TABLE(table,vasp_gui.mixpre,"MIXPRE=",0,1,1,2); + GUI_COMBOBOX_ADD(vasp_gui.mixpre,"0:NONE"); + GUI_COMBOBOX_ADD(vasp_gui.mixpre,"1:F=20 INVERSE KERKER"); + GUI_COMBOBOX_ADD(vasp_gui.mixpre,"2:F=200 INVERSE KERKER"); GUI_TOOLTIP(vasp_gui.mixpre,"MIXPRE: Ch. 6.49 DEFAULT: 1\nSelect the preconditioning for Broyden mixing."); /*empty: col1*/ - VASP_ENTRY_TABLE(vasp_gui.amix,vasp_gui.calc.amix,"%.4lf","AMIX=",2,3,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.amix,vasp_gui.calc.amix,"%.4lf","AMIX=",2,3,1,2); GUI_TOOLTIP(vasp_gui.amix,"AMIX: Ch. 6.49 DEFAULT: 0.4\nlinear mixing parameter\nDefault is 0.8 for ultrasoft pseudopotentials."); - VASP_ENTRY_TABLE(vasp_gui.bmix,vasp_gui.calc.bmix,"%.4lf","BMIX=",3,4,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.bmix,vasp_gui.calc.bmix,"%.4lf","BMIX=",3,4,1,2); GUI_TOOLTIP(vasp_gui.bmix,"BMIX: Ch. 6.49 DEFAULT: 1.0\ncutoff wavevector for Kerker mixing."); - VASP_ENTRY_TABLE(vasp_gui.amin,vasp_gui.calc.amin,"%.4lf","AMIN=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.amin,vasp_gui.calc.amin,"%.4lf","AMIN=",4,5,1,2); GUI_TOOLTIP(vasp_gui.amin,"AMIN: Ch. 6.49 DEFAULT: 0.1\nminimal mixing parameter."); /* 3rd line */ - VASP_COMBOBOX_TABLE(vasp_gui.inimix,"INIMIX=",0,1,2,3); - VASP_COMBOBOX_ADD(vasp_gui.inimix,"0:LINEAR"); - VASP_COMBOBOX_ADD(vasp_gui.inimix,"1:KERKER"); + GUI_COMBOBOX_TABLE(table,vasp_gui.inimix,"INIMIX=",0,1,2,3); + GUI_COMBOBOX_ADD(vasp_gui.inimix,"0:LINEAR"); + GUI_COMBOBOX_ADD(vasp_gui.inimix,"1:KERKER"); GUI_TOOLTIP(vasp_gui.inimix,"INIMIX: Ch. 6.49 DEFAULT: 1\ntype of initial mixing in Broyden mixing."); - VASP_ENTRY_TABLE(vasp_gui.maxmix,vasp_gui.calc.maxmix,"%i","MAXMIX=",1,2,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.maxmix,vasp_gui.calc.maxmix,"%i","MAXMIX=",1,2,2,3); GUI_TOOLTIP(vasp_gui.maxmix,"MAXMIX: Ch. 6.49 DEFAULT: -45\nMaximum number of steps stored in Broyden mixer."); - VASP_ENTRY_TABLE(vasp_gui.amix_mag,vasp_gui.calc.amix_mag,"%.4lf","AMIX_MAG=",2,3,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.amix_mag,vasp_gui.calc.amix_mag,"%.4lf","AMIX_MAG=",2,3,2,3); GUI_TOOLTIP(vasp_gui.amix_mag,"AMIX_MAG: Ch. 6.49 DEFAULT: 1.6\nlinear mixing parameter for magnetization."); - VASP_ENTRY_TABLE(vasp_gui.bmix_mag,vasp_gui.calc.bmix_mag,"%.4lf","BMIX_MAG=",3,4,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.bmix_mag,vasp_gui.calc.bmix_mag,"%.4lf","BMIX_MAG=",3,4,2,3); GUI_TOOLTIP(vasp_gui.bmix_mag,"BMIX_MAG: Ch. 6.49 DEFAULT: 1.0\ncutoff wavevector for Kerker mixing with magnetization."); - VASP_ENTRY_TABLE(vasp_gui.wc,vasp_gui.calc.wc,"%.1lf","WC=",4,5,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.wc,vasp_gui.calc.wc,"%.1lf","WC=",4,5,2,3); GUI_TOOLTIP(vasp_gui.wc,"WC: Ch. 6.49 DEFAULT: 1000\nstep weight factor for Broyden mixing."); /* initialize */ - VASP_COMBOBOX_SETUP(vasp_gui.mixer,3,vasp_mixer_selected); - VASP_COMBOBOX_SETUP(vasp_gui.mixpre,1,vasp_mixpre_selected); - VASP_COMBOBOX_SETUP(vasp_gui.inimix,1,vasp_inimix_selected); + GUI_COMBOBOX_SETUP(vasp_gui.mixer,3,vasp_mixer_selected); + GUI_COMBOBOX_SETUP(vasp_gui.mixpre,1,vasp_mixpre_selected); + GUI_COMBOBOX_SETUP(vasp_gui.inimix,1,vasp_inimix_selected); mixer_toggle(NULL,NULL); /* --- end frame */ /* --- projector */ @@ -3010,45 +3010,45 @@ GUI_TOOLTIP(vasp_gui.wc,"WC: Ch. 6.49 DEFAULT: 1000\nstep weight factor for Broy table = gtk_table_new(5, 4, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.lreal,"LREAL=",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.lreal,"Auto"); - VASP_COMBOBOX_ADD(vasp_gui.lreal,"On"); - VASP_COMBOBOX_ADD(vasp_gui.lreal,"TRUE"); - VASP_COMBOBOX_ADD(vasp_gui.lreal,"FALSE"); + GUI_COMBOBOX_TABLE(table,vasp_gui.lreal,"LREAL=",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.lreal,"Auto"); + GUI_COMBOBOX_ADD(vasp_gui.lreal,"On"); + GUI_COMBOBOX_ADD(vasp_gui.lreal,"TRUE"); + GUI_COMBOBOX_ADD(vasp_gui.lreal,"FALSE"); GUI_TOOLTIP(vasp_gui.lreal,"LREAL: Ch. 6.39 DEFAULT: FALSE\nDetermine whether projection operators are evaluated in\nreal-space or reciprocal-space."); /*empty: col2*/ - VASP_TEXT_TABLE(vasp_gui.ropt,vasp_gui.calc.ropt,"ROPT=",2,5,0,1); + GUI_TEXT_TABLE(table,vasp_gui.ropt,vasp_gui.calc.ropt,"ROPT=",2,5,0,1); GUI_TOOLTIP(vasp_gui.ropt,"ROPT: Ch. 6.39 DEFAULT: -\nROPT determine the precision of the real-space operator\nfor LREAL=AUTO and LREAL=On."); /* 2nd line */ /*empty: col1*/ - VASP_CHECK_TABLE(button,vasp_gui.calc.addgrid,NULL,"ADDGRID",1,2,1,2);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.addgrid,NULL,"ADDGRID",1,2,1,2);/*not calling anything*/ GUI_TOOLTIP(button,"ADDGRID: Ch. 6.63 DEFAULT: FALSE\nSelect the third fine grid for augmentation charge."); - VASP_ENTRY_TABLE(vasp_gui.lmaxmix,vasp_gui.calc.lmaxmix,"%i","LMAXMIX=",2,3,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.lmaxmix,vasp_gui.calc.lmaxmix,"%i","LMAXMIX=",2,3,1,2); GUI_TOOLTIP(vasp_gui.lmaxmix,"LMAXMIX: Ch. 6.63 DEFAULT: 2\nMaximum l-quantum number passed to charge density mixer."); /*empty: col4*/ - VASP_ENTRY_TABLE(vasp_gui.lmaxpaw,vasp_gui.calc.lmaxpaw,"%i","LMAXPAW=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.lmaxpaw,vasp_gui.calc.lmaxpaw,"%i","LMAXPAW=",4,5,1,2); GUI_TOOLTIP(vasp_gui.lmaxpaw,"LMAXPAW: Ch. 6.63 DEFAULT: 2*lmax\nMaximum l-quantum number for the evaluation of the PAW\non-site terms on the radial grid."); /* 3rd line */ /*empty: col1*/ - VASP_CHECK_TABLE(button,vasp_gui.calc.auto_grid,grid_toggle,"AUTO GRID",1,2,2,3); + GUI_CHECK_TABLE(table,button,vasp_gui.calc.auto_grid,grid_toggle,"AUTO GRID",1,2,2,3); GUI_TOOLTIP(button,"Automatically sets NG{X,Y,Z}, and NG{X,Y,Z}F."); - VASP_ENTRY_TABLE(vasp_gui.ngx,vasp_gui.calc.ngx,"%i","NGX=",2,3,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.ngx,vasp_gui.calc.ngx,"%i","NGX=",2,3,2,3); GUI_TOOLTIP(vasp_gui.ngx,"NGX: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the x direction."); - VASP_ENTRY_TABLE(vasp_gui.ngy,vasp_gui.calc.ngy,"%i","NGY=",3,4,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.ngy,vasp_gui.calc.ngy,"%i","NGY=",3,4,2,3); GUI_TOOLTIP(vasp_gui.ngy,"NGY: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the y direction."); - VASP_ENTRY_TABLE(vasp_gui.ngz,vasp_gui.calc.ngz,"%i","NGZ=",4,5,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.ngz,vasp_gui.calc.ngz,"%i","NGZ=",4,5,2,3); GUI_TOOLTIP(vasp_gui.ngz,"NGZ: Ch. 6.3 DEFAULT: -\nnumber of FFT-mesh grid-points along the z direction."); /* 4th line */ /*empty: col1*/ /*empty: col2*/ - VASP_ENTRY_TABLE(vasp_gui.ngxf,vasp_gui.calc.ngxf,"%i","NGXF=",2,3,3,4); + GUI_ENTRY_TABLE(table,vasp_gui.ngxf,vasp_gui.calc.ngxf,"%i","NGXF=",2,3,3,4); GUI_TOOLTIP(vasp_gui.ngxf,"NGXF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the x direction."); - VASP_ENTRY_TABLE(vasp_gui.ngyf,vasp_gui.calc.ngyf,"%i","NGYF=",3,4,3,4); + GUI_ENTRY_TABLE(table,vasp_gui.ngyf,vasp_gui.calc.ngyf,"%i","NGYF=",3,4,3,4); GUI_TOOLTIP(vasp_gui.ngyf,"NGYF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the y direction."); - VASP_ENTRY_TABLE(vasp_gui.ngzf,vasp_gui.calc.ngzf,"%i","NGZF=",4,5,3,4); + GUI_ENTRY_TABLE(table,vasp_gui.ngzf,vasp_gui.calc.ngzf,"%i","NGZF=",4,5,3,4); GUI_TOOLTIP(vasp_gui.ngzf,"NGZF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the z direction."); /* initialize */ - VASP_COMBOBOX_SETUP(vasp_gui.lreal,3,vasp_lreal_selected); + GUI_COMBOBOX_SETUP(vasp_gui.lreal,3,vasp_lreal_selected); grid_toggle(NULL,NULL); /* --- end frame */ From b0a887a9672cdc0d810b4ac62a2e7bb95a638fe6 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 25 Jul 2018 11:05:11 +0900 Subject: [PATCH 03/56] gui_uspex: prepare unified gui interface III. --- src/gui_vasp.c | 142 ++++++++++++++++++++++++------------------------- 1 file changed, 70 insertions(+), 72 deletions(-) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 4d68006..b67d85b 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -3065,18 +3065,18 @@ GUI_TOOLTIP(vasp_gui.ngzf,"NGZF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh gri table = gtk_table_new(4, 2, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ - VASP_ENTRY_TABLE(vasp_gui.ismear,vasp_gui.calc.ismear,"%i","ISMEAR=",0,1,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.ismear,vasp_gui.calc.ismear,"%i","ISMEAR=",0,1,0,1); GUI_TOOLTIP(vasp_gui.ismear,"ISMEAR: Ch. 6.38 DEFAULT: 1\nDetermine how the partial occupations are set.\nIt is advised to change it to ISMEAR=0\nfor semiconducting or insulating materials."); - VASP_ENTRY_TABLE(vasp_gui.sigma,vasp_gui.calc.sigma,"%.4lf","SIGMA=",1,2,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.sigma,vasp_gui.calc.sigma,"%.4lf","SIGMA=",1,2,0,1); GUI_TOOLTIP(vasp_gui.sigma,"SIGMA: Ch. 6.38 DEFAULT: 0.2\nDetermine the width of the smearing (eV)\nFor ISMEAR=0 (semiconductors or insulators)\na small SIGMA=0.05 can be chosen."); - VASP_CHECK_TABLE(vasp_gui.kgamma,vasp_gui.calc.kgamma,NULL,"KGAMMA",2,3,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.kgamma,vasp_gui.calc.kgamma,NULL,"KGAMMA",2,3,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.kgamma,"KGAMMA: Ch. 6.4 DEFAULT: TRUE\nWhen KPOINTS file is not present KGAMMA\nindicate if the k-grid is centered around gamma point."); - VASP_ENTRY_TABLE(vasp_gui.kspacing,vasp_gui.calc.kspacing,"%.4lf","KSPACING=",3,4,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.kspacing,vasp_gui.calc.kspacing,"%.4lf","KSPACING=",3,4,0,1); GUI_TOOLTIP(vasp_gui.kspacing,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS file is not present KSPACING\nDetermine the smallest spacing between k-points (Ang^-1)."); /* 2nd line */ - VASP_TEXT_TABLE(vasp_gui.fermwe,vasp_gui.calc.fermwe,"FERMWE=",0,2,1,2); + GUI_TEXT_TABLE(table,vasp_gui.fermwe,vasp_gui.calc.fermwe,"FERMWE=",0,2,1,2); GUI_TOOLTIP(vasp_gui.fermwe,"FERMWE: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 explicitly sets\noccupancy for each band."); - VASP_TEXT_TABLE(vasp_gui.fermdo,vasp_gui.calc.fermdo,"FERMDO=",2,4,1,2); + GUI_TEXT_TABLE(table,vasp_gui.fermdo,vasp_gui.calc.fermdo,"FERMDO=",2,4,1,2); GUI_TOOLTIP(vasp_gui.fermdo,"FERDO: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 and ISPIN=2 sets\noccupancy for down spin of each band."); /* --- end frame */ /* --- spin */ @@ -3086,20 +3086,20 @@ GUI_TOOLTIP(vasp_gui.fermdo,"FERDO: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 and ISPIN= table = gtk_table_new(5, 2,FALSE); gtk_container_add(GTK_CONTAINER(frame), table); /* 1st line */ - VASP_CHECK_TABLE(button,vasp_gui.calc.ispin,NULL,"SPIN POLARIZED",0,1,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.ispin,NULL,"SPIN POLARIZED",0,1,0,1);/*not calling anything*/ GUI_TOOLTIP(button,"ISPIN: Ch. 6.12 DEFAULT 1\nSpin polarized calculation sets ISPIN=2."); - VASP_CHECK_TABLE(vasp_gui.lnoncoll,vasp_gui.calc.non_collinear,lnoncoll_toggle,"NON COLLINEAR",1,2,0,1); + GUI_CHECK_TABLE(table,vasp_gui.lnoncoll,vasp_gui.calc.non_collinear,lnoncoll_toggle,"NON COLLINEAR",1,2,0,1); GUI_TOOLTIP(vasp_gui.lnoncoll,"LNONCOLLINEAR: Ch. 6.68.1 DEFAULT FALSE\nAllow to perform fully, non-collinear\nmagnetic structure calculations."); - VASP_CHECK_TABLE(vasp_gui.lsorbit,vasp_gui.calc.lsorbit,lsorbit_toggle,"LSORBIT",2,3,0,1); + GUI_CHECK_TABLE(table,vasp_gui.lsorbit,vasp_gui.calc.lsorbit,lsorbit_toggle,"LSORBIT",2,3,0,1); GUI_TOOLTIP(vasp_gui.lsorbit,"LSORBIT: Ch. 6.68.2 DEFAULT: FALSE\nSwitch on spin-orbit coupling (for PAW)\nautomatically sets LNONCOLLINEAR when TRUE."); - VASP_CHECK_TABLE(button,vasp_gui.calc.gga_compat,NULL,"GGA_COMPAT",3,4,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.gga_compat,NULL,"GGA_COMPAT",3,4,0,1);/*not calling anything*/ GUI_TOOLTIP(button,"GGA_COMPAT: Ch. 6.42 DEFAULT: TRUE\nRestores the lattice symmetry\nfor gradient corrected functionals."); - VASP_ENTRY_TABLE(vasp_gui.nupdown,vasp_gui.calc.nupdown,"%.1f","NUPDOWN=",4,5,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.nupdown,vasp_gui.calc.nupdown,"%.1f","NUPDOWN=",4,5,0,1); GUI_TOOLTIP(vasp_gui.nupdown,"NUPDOWN: Ch. 6.36 DEFAULT -1\nSets the difference between number\nof electrons in up and down spin component."); /* 2nd line */ - VASP_TEXT_TABLE(vasp_gui.magmom,vasp_gui.calc.magmom,"MAGMOM=",0,3,1,2); + GUI_TEXT_TABLE(table,vasp_gui.magmom,vasp_gui.calc.magmom,"MAGMOM=",0,3,1,2); GUI_TOOLTIP(vasp_gui.magmom,"MAGMOM: Ch. 6.13 DEFAULT: NIONS\nSets the initial magnetic moment for each atom\nuseful only for calculation with no WAVECAR or CHGCAR\nor magnetic calculations from a non-magnetic start.\nFor non-collinear calculations default value is 3*NIONS."); - VASP_TEXT_TABLE(vasp_gui.saxis,vasp_gui.calc.saxis,"SAXIS=",3,5,1,2); + GUI_TEXT_TABLE(table,vasp_gui.saxis,vasp_gui.calc.saxis,"SAXIS=",3,5,1,2); GUI_TOOLTIP(vasp_gui.saxis,"SAXIS: Ch. 6.68.2 DEFAULT -\nSets the quantisation axis for spin.\nThe default is SAXIS = eps 0 1\nwhere eps is a small quantity."); /* --- end frame */ /* --- exchange correlation */ @@ -3108,67 +3108,66 @@ GUI_TOOLTIP(vasp_gui.saxis,"SAXIS: Ch. 6.68.2 DEFAULT -\nSets the quantisation a /* create a table in the frame*/ table = gtk_table_new(5, 5,FALSE); gtk_container_add(GTK_CONTAINER(frame), table); -// gtk_container_set_border_width(GTK_CONTAINER(table), PANEL_SPACING);/*useful?*/ /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.gga,"GGA=",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.gga,"91:PW91"); - VASP_COMBOBOX_ADD(vasp_gui.gga,"PE:PBE"); - VASP_COMBOBOX_ADD(vasp_gui.gga,"RP:rPBE"); - VASP_COMBOBOX_ADD(vasp_gui.gga,"AM:AM05"); - VASP_COMBOBOX_ADD(vasp_gui.gga,"PS:PBEsol"); + GUI_COMBOBOX_TABLE(table,vasp_gui.gga,"GGA=",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.gga,"91:PW91"); + GUI_COMBOBOX_ADD(vasp_gui.gga,"PE:PBE"); + GUI_COMBOBOX_ADD(vasp_gui.gga,"RP:rPBE"); + GUI_COMBOBOX_ADD(vasp_gui.gga,"AM:AM05"); + GUI_COMBOBOX_ADD(vasp_gui.gga,"PS:PBEsol"); GUI_TOOLTIP(vasp_gui.gga,"GGA: Ch. 6.40 DEFAULT -\nSets the gradient corrected functional.\nThe default is selected according to the POTCAR file."); - VASP_CHECK_TABLE(button,vasp_gui.calc.voskown,NULL,"VOSKOWN",1,2,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.voskown,NULL,"VOSKOWN",1,2,0,1);/*not calling anything*/ GUI_TOOLTIP(button,"VOSKOWN: Ch. 6.41 DEFAULT 0\nSets the Vosko, Wilk and Nusair method\nfor interpolation of correlation functional).\nUseful only if GGA=91 (PW91)."); /*empty: col2*/ /*empty: col3*/ /*empty: col4*/ /* 2nd line */ - VASP_COMBOBOX_TABLE(vasp_gui.metagga,"METAGGA=",0,1,1,2); - VASP_COMBOBOX_ADD(vasp_gui.metagga,"TPSS"); - VASP_COMBOBOX_ADD(vasp_gui.metagga,"rTPSS"); - VASP_COMBOBOX_ADD(vasp_gui.metagga,"M06L"); - VASP_COMBOBOX_ADD(vasp_gui.metagga,"MBJ"); + GUI_COMBOBOX_TABLE(table,vasp_gui.metagga,"METAGGA=",0,1,1,2); + GUI_COMBOBOX_ADD(vasp_gui.metagga,"TPSS"); + GUI_COMBOBOX_ADD(vasp_gui.metagga,"rTPSS"); + GUI_COMBOBOX_ADD(vasp_gui.metagga,"M06L"); + GUI_COMBOBOX_ADD(vasp_gui.metagga,"MBJ"); GUI_TOOLTIP(vasp_gui.metagga,"METAGGA: Ch. 6.43 DEFAULT none\nSets the meta-GGA functional."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lmetagga,metagga_toggle,"LMETAGGA",1,2,1,2); + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lmetagga,metagga_toggle,"LMETAGGA",1,2,1,2); GUI_TOOLTIP(button,"LMETAGGA (secret) DEFAULT FALSE\nIgnored (but recognized and read) by VASP.\nUsed (here) to enable a METAGGA calculation."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lasph,NULL,"LASPH",2,3,1,2);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lasph,NULL,"LASPH",2,3,1,2);/*not calling anything*/ GUI_TOOLTIP(button,"LASPH: Ch. 6.44 DEFAULT FALSE\nSets calculation of non-spherical contributions\nfrom the gradient corrections in PAW spheres."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lmixtau,NULL,"LMIXTAU",3,4,1,2);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lmixtau,NULL,"LMIXTAU",3,4,1,2);/*not calling anything*/ GUI_TOOLTIP(button,"LMIXTAU: Ch. 6.43.2 DEFAULT FALSE\nSets inclusion of kinetic energy density\nto the mixer (useful to converge METAGGA)."); - VASP_ENTRY_TABLE(vasp_gui.lmaxtau,vasp_gui.calc.lmaxtau,"%i","LMAXTAU=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.lmaxtau,vasp_gui.calc.lmaxtau,"%i","LMAXTAU=",4,5,1,2); GUI_TOOLTIP(vasp_gui.lmaxtau,"LMAXTAU: Ch. 6.43.1 DEFAULT 0\nSets maximum l-quantum number\nto calculate PAW one-center expansion\nof the kinetic energy density.\nDefault is 6 if LASPH is set to TRUE."); /* 3rd line */ - VASP_TEXT_TABLE(vasp_gui.cmbj,vasp_gui.calc.cmbj,"CMBJ=",0,3,2,3); + GUI_TEXT_TABLE(table,vasp_gui.cmbj,vasp_gui.calc.cmbj,"CMBJ=",0,3,2,3); GUI_TOOLTIP(vasp_gui.cmbj,"CMBJ: Ch 6.43 DEFAULT: -\nFor MBJ meta-GGA calculations CMBJ\nsets the mixing coefficient for Becke-Roussel potential\nfor each species or constant if CMBJ has only one value."); - VASP_ENTRY_TABLE(vasp_gui.cmbja,vasp_gui.calc.cmbja,"%.4lf","CMBJA=",3,4,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.cmbja,vasp_gui.calc.cmbja,"%.4lf","CMBJA=",3,4,2,3); GUI_TOOLTIP(vasp_gui.cmbja,"CMBJA: Ch. 6.43 DEFAULT -0.012\nAlpha parameter to calculate CMBJ\nSelfconsistently at each electronic step.\nUnused if CMBJ is specified."); - VASP_ENTRY_TABLE(vasp_gui.cmbjb,vasp_gui.calc.cmbjb,"%.4lf","CMBJB=",4,5,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.cmbjb,vasp_gui.calc.cmbjb,"%.4lf","CMBJB=",4,5,2,3); GUI_TOOLTIP(vasp_gui.cmbjb,"CMBJB: Ch. 6.43 DEFAULT 1.023\nBeta parameter to calculate CMBJ\nSelfconsistently at each electronic step.\nUnused if CMBJ is specified."); /* 4th line */ - VASP_COMBOBOX_TABLE(vasp_gui.ldau,"LDAUTYPE=",0,1,3,4); - VASP_COMBOBOX_ADD(vasp_gui.ldau,"1:LSDA+U Liechtenstein"); - VASP_COMBOBOX_ADD(vasp_gui.ldau,"2:LSDA+U Dudarev"); - VASP_COMBOBOX_ADD(vasp_gui.ldau,"4:LDA+U Liechtenstein"); + GUI_COMBOBOX_TABLE(table,vasp_gui.ldau,"LDAUTYPE=",0,1,3,4); + GUI_COMBOBOX_ADD(vasp_gui.ldau,"1:LSDA+U Liechtenstein"); + GUI_COMBOBOX_ADD(vasp_gui.ldau,"2:LSDA+U Dudarev"); + GUI_COMBOBOX_ADD(vasp_gui.ldau,"4:LDA+U Liechtenstein"); GUI_TOOLTIP(vasp_gui.ldau,"LDAUTYPE: Ch. 6.70 DEFAULT: 2\nSets the type of L(S)DA+U calculation."); - VASP_CHECK_TABLE(button,vasp_gui.calc.ldau,ldau_toggle,"LDAU",1,2,3,4); + GUI_CHECK_TABLE(table,button,vasp_gui.calc.ldau,ldau_toggle,"LDAU",1,2,3,4); GUI_TOOLTIP(button,"LDAU: Ch. 6.70 DEFAULT: FALSE\nSwitches on L(S)DA+U calculation."); - VASP_TEXT_TABLE(vasp_gui.ldaul,vasp_gui.calc.ldaul,"LDAUL=",2,5,3,4); + GUI_TEXT_TABLE(table,vasp_gui.ldaul,vasp_gui.calc.ldaul,"LDAUL=",2,5,3,4); GUI_TOOLTIP(vasp_gui.ldaul,"LDAUL: Ch. 6.70 DEFAULT: 2\nSets the l-quantum number (for each species)\nfor which the on-site interaction is added."); /* 5th line */ - VASP_COMBOBOX_TABLE(vasp_gui.ldau_print,"LDAUPRINT=",0,1,4,5); - VASP_COMBOBOX_ADD(vasp_gui.ldau_print,"0:Silent"); - VASP_COMBOBOX_ADD(vasp_gui.ldau_print,"1:Occupancy matrix"); - VASP_COMBOBOX_ADD(vasp_gui.ldau_print,"2:Full output"); + GUI_COMBOBOX_TABLE(table,vasp_gui.ldau_print,"LDAUPRINT=",0,1,4,5); + GUI_COMBOBOX_ADD(vasp_gui.ldau_print,"0:Silent"); + GUI_COMBOBOX_ADD(vasp_gui.ldau_print,"1:Occupancy matrix"); + GUI_COMBOBOX_ADD(vasp_gui.ldau_print,"2:Full output"); GUI_TOOLTIP(vasp_gui.ldau_print,"LDAUPRINT: Ch. 6.70 DEFAULT 0\nSets the level of verbosity of L(S)DA+U."); - VASP_TEXT_TABLE(vasp_gui.ldauu,vasp_gui.calc.ldauu,"LDAUU=",1,3,4,5); + GUI_TEXT_TABLE(table,vasp_gui.ldauu,vasp_gui.calc.ldauu,"LDAUU=",1,3,4,5); GUI_TOOLTIP(vasp_gui.ldauu,"LDAUU: Ch. 6.70 DEFAULT: -\nSets effective on-site Coulomb interaction (for each species)."); - VASP_TEXT_TABLE(vasp_gui.ldauj,vasp_gui.calc.ldauj,"LDAUJ=",3,5,4,5); + GUI_TEXT_TABLE(table,vasp_gui.ldauj,vasp_gui.calc.ldauj,"LDAUJ=",3,5,4,5); GUI_TOOLTIP(vasp_gui.ldauj,"LDAUJ: Ch. 6.70 DEFAULT: -\nSets effective on-site Exchange interaction (for each species)."); /* initialize */ - VASP_COMBOBOX_SETUP(vasp_gui.gga,1,vasp_gga_selected); - VASP_COMBOBOX_SETUP(vasp_gui.metagga,3,vasp_metagga_selected); - VASP_COMBOBOX_SETUP(vasp_gui.ldau,1,vasp_ldau_selected); - VASP_COMBOBOX_SETUP(vasp_gui.ldau_print,0,vasp_ldau_print_selected); + GUI_COMBOBOX_SETUP(vasp_gui.gga,1,vasp_gga_selected); + GUI_COMBOBOX_SETUP(vasp_gui.metagga,3,vasp_metagga_selected); + GUI_COMBOBOX_SETUP(vasp_gui.ldau,1,vasp_ldau_selected); + GUI_COMBOBOX_SETUP(vasp_gui.ldau_print,0,vasp_ldau_print_selected); metagga_toggle(NULL,NULL);/*initialize TODO: move to end*/ ldau_toggle(NULL,NULL);/*initialize TODO: move to end*/ /* --- end frame */ @@ -3178,43 +3177,42 @@ GUI_TOOLTIP(vasp_gui.ldauj,"LDAUJ: Ch. 6.70 DEFAULT: -\nSets effective on-site E /* create a table in the frame*/ table = gtk_table_new(2, 5,FALSE); gtk_container_add(GTK_CONTAINER(frame), table); -// gtk_container_set_border_width(GTK_CONTAINER(table), PANEL_SPACING);/*useful?*/ /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.idipol,"IDIPOL=",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.idipol,"0:no calcul"); - VASP_COMBOBOX_ADD(vasp_gui.idipol,"1:u axis"); - VASP_COMBOBOX_ADD(vasp_gui.idipol,"2:v axis"); - VASP_COMBOBOX_ADD(vasp_gui.idipol,"3:w axis"); - VASP_COMBOBOX_ADD(vasp_gui.idipol,"4:all axis"); + GUI_COMBOBOX_TABLE(table,vasp_gui.idipol,"IDIPOL=",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.idipol,"0:no calcul"); + GUI_COMBOBOX_ADD(vasp_gui.idipol,"1:u axis"); + GUI_COMBOBOX_ADD(vasp_gui.idipol,"2:v axis"); + GUI_COMBOBOX_ADD(vasp_gui.idipol,"3:w axis"); + GUI_COMBOBOX_ADD(vasp_gui.idipol,"4:all axis"); GUI_TOOLTIP(vasp_gui.idipol,"IDIPOL: Ch. 6.64 DEFAULT: -\nSets the direction of the calculated dipole moment\nparallel to the 1st (1), 2nd (2) or 3rd (3) lattice vector.\nIDIPOL=4 trigger full dipole calculation\n0 switches off dipole calculation (remove IDIPOL)."); - VASP_CHECK_TABLE(vasp_gui.ldipol,vasp_gui.calc.ldipol,NULL,"LDIPOL",1,2,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.ldipol,vasp_gui.calc.ldipol,NULL,"LDIPOL",1,2,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.ldipol,"LDIPOL: Ch. 6.64 DEFAULT: FALSE\nSets potential dipole correction of the\nslab/molecule periodic-boundary induced errors."); - VASP_CHECK_TABLE(vasp_gui.lmono,vasp_gui.calc.lmono,NULL,"LMONO",2,3,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.lmono,vasp_gui.calc.lmono,NULL,"LMONO",2,3,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.lmono,"LMONO: Ch. 6.64 DEFAULT: FALSE\nSets potential monopole correction of the\nslab/molecule periodic-boundary induced errors."); - VASP_TEXT_TABLE(vasp_gui.dipol,vasp_gui.calc.dipol,"DIPOL=",3,5,0,1); + GUI_TEXT_TABLE(table,vasp_gui.dipol,vasp_gui.calc.dipol,"DIPOL=",3,5,0,1); GUI_TOOLTIP(vasp_gui.dipol,"DIPOL: Ch. 6.64 DEFAULT: -\nSets the center of the net charge distribution.\nIf left blank a guess value is sets at runtime."); /* 2nd line */ /*empty: col0*/ /*empty: col1*/ /*empty: col2*/ - VASP_ENTRY_TABLE(vasp_gui.epsilon,vasp_gui.calc.epsilon,"%.4lf","EPSILON=",3,4,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.epsilon,vasp_gui.calc.epsilon,"%.4lf","EPSILON=",3,4,2,3); GUI_TOOLTIP(vasp_gui.epsilon,"EPSILON: Ch. 6.64 DEFAULT: 1\nSets the dielectric constant of the medium."); - VASP_ENTRY_TABLE(vasp_gui.efield,vasp_gui.calc.efield,"%.4lf","EFIELD=",4,5,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.efield,vasp_gui.calc.efield,"%.4lf","EFIELD=",4,5,2,3); GUI_TOOLTIP(vasp_gui.efield,"EFIELD: Ch. 6.64 DEFAULT: 0\nApply an external electrostatic field\nin a slab, or molecule calculation.\nOnly a single component can be given\nparallel to IDIPOL direction (1-3)."); /*initialize sensitive widget*/ - VASP_COMBOBOX_SETUP(vasp_gui.idipol,0,vasp_idipol_selected); + GUI_COMBOBOX_SETUP(vasp_gui.idipol,0,vasp_idipol_selected); if(vasp_gui.calc.idipol!=VID_0) { - gtk_widget_set_sensitive(vasp_gui.ldipol,TRUE); - gtk_widget_set_sensitive(vasp_gui.lmono,TRUE); - gtk_widget_set_sensitive(vasp_gui.dipol,TRUE); - gtk_widget_set_sensitive(vasp_gui.epsilon,TRUE); - if(vasp_gui.calc.idipol!=VID_4) gtk_widget_set_sensitive(vasp_gui.efield,TRUE); + GUI_UNLOCK(vasp_gui.ldipol); + GUI_UNLOCK(vasp_gui.lmono); + GUI_UNLOCK(vasp_gui.dipol); + GUI_UNLOCK(vasp_gui.epsilon); + if(vasp_gui.calc.idipol!=VID_4) GUI_UNLOCK(vasp_gui.efield); }else{ - gtk_widget_set_sensitive(vasp_gui.ldipol,FALSE); - gtk_widget_set_sensitive(vasp_gui.lmono,FALSE); - gtk_widget_set_sensitive(vasp_gui.dipol,FALSE); - gtk_widget_set_sensitive(vasp_gui.epsilon,FALSE); - gtk_widget_set_sensitive(vasp_gui.efield,FALSE); + GUI_LOCK(vasp_gui.ldipol); + GUI_LOCK(vasp_gui.lmono); + GUI_LOCK(vasp_gui.dipol); + GUI_LOCK(vasp_gui.epsilon); + GUI_LOCK(vasp_gui.efield); } /* --- end frame */ From 277d9c169d256fb9e2dd8fb16c6a2660152f4b4a Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 25 Jul 2018 14:55:34 +0900 Subject: [PATCH 04/56] gui_uspex: prepare unified gui interface IV. --- src/gui_defs.h | 102 ++++++++++++++--- src/gui_vasp.c | 301 +++++++++++++++++-------------------------------- 2 files changed, 189 insertions(+), 214 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index 0aeea74..04e6d06 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -33,16 +33,22 @@ The GNU GPL can also be found at http://www.gnu.org /*****************/ /* BOX INTERFACE */ /*****************/ -/*Set a new horizontal box (hbox) in a vertical box (vbox).*/ -#define GUI_NEW_LINE(vbox,hbox) do{\ +/*Create a new frame (frame) in box (box)*/ +/*Q: add? gtk_container_set_border_width(GTK_CONTAINER(frame), GUI_SPACE);*/ +#define GUI_FRAME_BOX(box,frame) do{\ + frame = gtk_frame_new(NULL);\ + gtk_box_pack_start(GTK_BOX(box),frame,FALSE,FALSE,0);\ +}while(0) +/*Set a new horizontal box (hbox) in a box (box).*/ +#define GUI_LINE_BOX(box,hbox) do{\ hbox = gtk_hbox_new(FALSE, 0);\ gtk_container_set_border_width(GTK_CONTAINER(hbox), GUI_SPACE);\ - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);\ + gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 0);\ }while(0) -/*Set a new label (label) with text ("text") in an horizontal box (hbox).*/ -#define GUI_NEW_LABEL(hbox,label,text) do{\ +/*Set a new label (label) with text ("text") in a box (box).*/ +#define GUI_LABEL_BOX(box,label,text) do{\ label = gtk_label_new(text);\ - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);\ + gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 0);\ }while(0) /*Set a new text entry (entry) with initial value ("value") expanding (wilde=TRUE) or not (wilde=FALSE) in an horizontal box (hbox).*/ #define GUI_TEXT_ENTRY(hbox,entry,value,wilde) do{\ @@ -74,29 +80,87 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(combo)->entry),default_text);\ g_signal_connect(GTK_OBJECT(GTK_COMBO(combo)->entry), "changed",GTK_SIGNAL_FUNC(function),data);\ }while(0) +/*Create can open button (button) connected on click to function (function) in box (box).*/ +#define GUI_OPEN_BUTTON_BOX(box,button,function) do{\ + button=gtk_button_new_from_stock(GTK_STOCK_OPEN);\ + gtk_box_pack_end(GTK_BOX(box), button, FALSE, FALSE, 0);\ + g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ +}while(0) +/*Create an gtk-absurdly complex uneditable, scrollable textview (tv) with textbuffer (tv_buffer), in a box (box).*/ +#define GUI_TEXTVIEW_BOX(box,tv,tv_buffer) do{\ + GtkWidget *_absurd = gtk_scrolled_window_new(NULL, NULL);\ + tv = gtk_text_view_new();\ + tv_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv));\ + gtk_text_view_set_editable(GTK_TEXT_VIEW(tv),FALSE);\ + GUI_LOCK(tv);\ + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(_absurd),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);\ + gtk_container_add(GTK_CONTAINER(_absurd),tv);\ + gtk_container_set_border_width(GTK_CONTAINER(_absurd),1);\ + gtk_box_pack_start(GTK_BOX(box),_absurd,TRUE,TRUE,0);\ +}while(0) +/**********************/ +/* NOTEBOOK INTERFACE */ +/**********************/ +/*create a new page (page) with label ("caption") in notebook (notebook).*/ +#define GUI_PAGE_NOTE(notebook,page,caption) do{\ + GtkWidget *_label = gtk_label_new(caption);\ + page = gtk_vbox_new(FALSE, GUI_SPACE);\ + gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,_label);\ +}while(0) +/*Create a new frame (frame) with label ("caption") in a notebook page (page).*/ +#define GUI_FRAME_NOTE(page,frame,caption) do{\ + frame = gtk_frame_new(caption);\ + gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0);\ +}while(0) +/*******************/ +/* FRAME INTERFACE */ +/*******************/ +/*Create a new vertical box (vbox) in a frame (frame).*/ +#define GUI_VBOX_FRAME(frame,vbox) do{\ + vbox = gtk_vbox_new(FALSE, GUI_SPACE);\ + gtk_container_add(GTK_CONTAINER(frame), vbox);\ +}while(0) +/*Create a new unexpanded (row) x (col) table (table) in a frame (frame).*/ +#define GUI_TABLE_FRAME(frame,table,row,col) do{\ + table = gtk_table_new(row, col, FALSE);\ + gtk_container_add(GTK_CONTAINER(frame), table);\ +}while(0) +/*Create a new toptab notebook (notebook) with border in a frame (frame).*/ +#define GUI_NOTE_FRAME(frame,notebook) do{\ + notebook = gtk_notebook_new();\ + gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP);\ + gtk_container_add(GTK_CONTAINER(frame), notebook);\ + gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), TRUE);\ +}while(0) /************************************************************************************/ /* TABLE INTERFACE: */ /* all of the *_TABLE() defines set a new table cell @l,r,t,b in table (table).*/ /************************************************************************************/ /*Create a new cell with: - * a boxed label (created with GUI_NEW_LABEL) with text ("caption"), + * a label with text ("text")*/ +#define GUI_LABEL_TABLE(table,text,l,r,t,b) do{\ + GtkWidget *_label = gtk_label_new(text);\ + gtk_table_attach_defaults(GTK_TABLE(table),_label,l,r,t,b);\ +}while(0) +/*Create a new cell with: + * a boxed label (created with GUI_LABEL_BOX) with text ("caption"), * an expanded text entry (entry, created with GUI_TEXT_ENTRY) with a default value ("value").*/ #define GUI_TEXT_TABLE(table,entry,value,caption,l,r,t,b) do{\ GtkWidget *_label;\ GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ - GUI_NEW_LABEL(_hbox,_label,caption);\ + GUI_LABEL_BOX(_hbox,_label,caption);\ GUI_TEXT_ENTRY(_hbox,entry,value,TRUE);\ gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ }while(0) /*Create a new cell with: - * a boxed label (created with GUI_NEW_LABEL) with text ("caption"), + * a boxed label (created with GUI_LABEL_BOX) with text ("caption"), * a boxed separator, * a sized-8 boxed entry (entry, created with GUI_ENTRY) with an initial value (value) of format ("format").*/ #define GUI_ENTRY_TABLE(table,entry,value,format,caption,l,r,t,b) do{\ GtkWidget *_separator;\ GtkWidget *_label;\ GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ - GUI_NEW_LABEL(_hbox,_label,caption);\ + GUI_LABEL_BOX(_hbox,_label,caption);\ GUI_NEW_SEPARATOR(_hbox,_separator);\ GUI_ENTRY(_hbox,entry,value,format,8);\ gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ @@ -109,7 +173,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ }while(0) /*Create a new cell with: - * a boxed label (created with GUI_NEW_LABEL) with text ("caption"), + * a boxed label (created with GUI_LABEL_BOX) with text ("caption"), * a boxed separator, * a boxed combo (combo,created with GUI_REG_COMBO) linked to GLIST (list) which is FREED after GUI_REG_COMBO. * */ @@ -119,7 +183,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ GtkWidget *_label;\ GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ - GUI_NEW_LABEL(_hbox,_label,caption);\ + GUI_LABEL_BOX(_hbox,_label,caption);\ GUI_NEW_SEPARATOR(_hbox,_separator);\ GUI_REG_COMBO(hbox,combo,list,default_text,function);\ gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ @@ -188,7 +252,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ * a boxed label with text ("caption"), * a separator. * a.k.a. a left aligned label.*/ -#define GUI_LABEL_TABLE(table,caption,l,r,t,b) do{\ +#define GUI_LEFT_LABEL_TABLE(table,caption,l,r,t,b) do{\ GtkWidget *_separator;\ GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ GtkWidget *_label = gtk_label_new(caption);\ @@ -196,11 +260,17 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ GUI_NEW_SEPARATOR(_hbox,_separator);\ gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ }while(0) -/************************/ -/* GENERAL GTK COMMANDS */ -/************************/ +/********************/ +/* GENERAL COMMANDS */ +/********************/ /*create a tooltip with text ("text") for the widget (widget).*/ #define GUI_TOOLTIP(widget,text) gtk_widget_set_tooltip_text(widget,text) +/*set the entry (entry) text ("text")*/ +#define GUI_ENTRY_TEXT(entry,text) gtk_entry_set_text(GTK_ENTRY(entry),text); /*set sensitivity of a widget*/ #define GUI_LOCK(widget) gtk_widget_set_sensitive(widget,FALSE) #define GUI_UNLOCK(widget) gtk_widget_set_sensitive(widget,TRUE) + + + + diff --git a/src/gui_vasp.c b/src/gui_vasp.c index b67d85b..4cdf6d5 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -2721,50 +2721,33 @@ void gui_vasp_dialog(void){ g_free(title); vasp_gui.window = dialog_window(dialog); /* --- Outside of notebook */ - frame = gtk_frame_new(NULL); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(vasp_gui.window)->vbox), frame, FALSE, FALSE, 0); - vbox = gtk_vbox_new(FALSE, _SPACE); - gtk_container_add(GTK_CONTAINER(frame), vbox); + GUI_FRAME_BOX(GTK_DIALOG(vasp_gui.window)->vbox,frame); + GUI_VBOX_FRAME(frame,vbox); /* --- MODEL NAME */ - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, _SPACE); - label = gtk_label_new(g_strdup_printf("MODEL NAME")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + GUI_LINE_BOX(vbox,hbox); + GUI_LABEL_BOX(hbox,label,"MODEL NAME"); GUI_TEXT_ENTRY(hbox,vasp_gui.name,data->basename,TRUE); GUI_TOOLTIP(vasp_gui.name,"The model name will be used in VASP files\nas well as GDIS display."); /* --- CONNECTED XML */ - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, _SPACE); - label = gtk_label_new(g_strdup_printf("CONNECTED XML")); - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); + GUI_LINE_BOX(vbox,hbox); + GUI_LABEL_BOX(hbox,label,"CONNECTED XML"); GUI_TEXT_ENTRY(hbox,vasp_gui.file_entry,data->filename,TRUE); - if(data->id!=VASP) gtk_entry_set_text(GTK_ENTRY(vasp_gui.file_entry),""); + if(data->id!=VASP) GUI_ENTRY_TEXT(vasp_gui.file_entry,""); GUI_TOOLTIP(vasp_gui.file_entry,"Use the result of a calculation (vasprun.xml)\nas a model to fill up settings of the current one.\nNOTE: important settings (such as NELM) will be wrong\nand all settings should be checked again. Carefully."); - button=gtk_button_new_from_stock(GTK_STOCK_OPEN); - gtk_box_pack_end(GTK_BOX(hbox), button, FALSE, FALSE, 0); - g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(load_vasprun_dialog),NULL); -/* notebook frame */ - frame = gtk_frame_new(NULL); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(vasp_gui.window)->vbox), frame, FALSE, FALSE, 0); - gtk_container_set_border_width(GTK_CONTAINER(frame), _SPACE); -/* create notebook */ - notebook = gtk_notebook_new(); - gtk_notebook_set_tab_pos(GTK_NOTEBOOK(notebook), GTK_POS_TOP); - gtk_container_add(GTK_CONTAINER(frame), notebook); - gtk_notebook_set_show_border(GTK_NOTEBOOK(notebook), TRUE); + GUI_OPEN_BUTTON_BOX(hbox,button,load_vasprun_dialog); +/* create frame in box */ + GUI_FRAME_BOX(GTK_DIALOG(vasp_gui.window)->vbox,frame); +/* create notebook in frame */ + GUI_NOTE_FRAME(frame,notebook); /*------------------*/ /* page 0 -> PRESET */ /*------------------*/ - page = gtk_vbox_new(FALSE, _SPACE); - label = gtk_label_new("PRESET"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,label); + GUI_PAGE_NOTE(notebook,page,"PRESET"); /* --- general */ - frame = gtk_frame_new("General"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"General"); /* create a table in the frame*/ - table = gtk_table_new(5, 4, FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,5,4); /* 1st line */ GUI_COMBOBOX_TABLE(table,vasp_gui.simple_calcul,"CALCUL:",0,1,0,1); GUI_COMBOBOX_ADD(vasp_gui.simple_calcul,"Energy (single point)"); @@ -2803,7 +2786,7 @@ GUI_TOOLTIP(vasp_gui.simple_species,"From POTCAR file, the following species are GUI_TOOLTIP(vasp_gui.simple_potcar,"Where is the POTCAR file for this calculation?"); GUI_BUTTON_TABLE(table,vasp_gui.simple_potcar_button,GTK_STOCK_OPEN,load_potcar_file_dialog,3,4,3,4); /* 5th line */ - GUI_LABEL_TABLE(table,"EXEC:",0,1,4,5); + GUI_LEFT_LABEL_TABLE(table,"EXEC:",0,1,4,5); GUI_SPIN_TABLE(table,vasp_gui.simple_np,vasp_gui.calc.job_nproc,parallel_eq,"NP=",1,2,4,5); GUI_TOOLTIP(vasp_gui.simple_np,"How many CPU(s) should be used for calculation?"); GUI_SPIN_TABLE(table,vasp_gui.simple_ncore,vasp_gui.calc.ncore,parallel_eq,"NCORE=",2,3,4,5); @@ -2816,57 +2799,36 @@ GUI_TOOLTIP(vasp_gui.simple_kpar,"How many k-points should be worked on at a tim GUI_COMBOBOX_SETUP(vasp_gui.simple_kgrid,0,NULL);/*not calling anything*/ /* --- end frame */ /* --- DISCLAMER */ - frame = gtk_frame_new("DISCLAMER"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"DISCLAMER"); /* create a table in the frame*/ - table = gtk_table_new(4, 3,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,4,3); /* 1st line */ - label = gtk_label_new("This simplified interface is aimed at pre-loading parameters with default values"); - gtk_table_attach_defaults(GTK_TABLE(table),label,1,2,0,1); + GUI_LABEL_TABLE(table,"This simplified interface is aimed at pre-loading parameters with default values",1,2,0,1); /* 2nd line */ - label = gtk_label_new("for a given calculation type. User should then check said defaults extremely carefuly..."); - gtk_table_attach_defaults(GTK_TABLE(table),label,1,2,1,2); + GUI_LABEL_TABLE(table,"for a given calculation type. User should then check said defaults extremely carefuly...",1,2,1,2); /* 3th line */ - label = gtk_label_new("GENERATE ==>"); - gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,3,4); + GUI_LABEL_TABLE(table,"GENERATE ==>",0,1,3,4); GUI_BUTTON_TABLE(table,vasp_gui.simple_apply,GTK_STOCK_APPLY,vasp_apply_simple,1,2,3,4); GUI_TOOLTIP(vasp_gui.simple_apply,"Use this to obtain a preset of setting.\nIf calculation is already set using this will\noverwrite settings resulting in an unpredictable state."); - label = gtk_label_new("<== (and check...)"); - gtk_table_attach_defaults(GTK_TABLE(table),label,2,3,3,4); + GUI_LABEL_TABLE(table,"<== (and check...)",2,3,3,4); /* --- end frame */ /* --- MESSAGE */ - frame = gtk_frame_new("MESSAGE"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); -/*create a vbox in frame*/ - vbox=gtk_vbox_new(TRUE, 0); - gtk_container_add(GTK_CONTAINER(frame),vbox); -/* num frames */ - vasp_gui.simple_message=gtk_text_view_new(); - vasp_gui.simple_message_buff=gtk_text_view_get_buffer(GTK_TEXT_VIEW(vasp_gui.simple_message)); - gtk_text_view_set_editable(GTK_TEXT_VIEW(vasp_gui.simple_message),FALSE); - gtk_widget_set_sensitive(vasp_gui.simple_message,FALSE); - button=gtk_scrolled_window_new(NULL, NULL);/*GTK-ABSURD*/ - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(button),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC); - gtk_container_add(GTK_CONTAINER(button),vasp_gui.simple_message); - gtk_container_set_border_width(GTK_CONTAINER(button),1); - gtk_box_pack_start(GTK_BOX(vbox),button,TRUE,TRUE,0); + GUI_FRAME_NOTE(page,frame,"MESSAGE"); +/* create a vbox in frame*/ + GUI_VBOX_FRAME(frame,vbox); +/* create a textview in a frame */ + GUI_TEXTVIEW_BOX(vbox,vasp_gui.simple_message,vasp_gui.simple_message_buff); /* --- end frame */ - /*-----------------------*/ /* page 1 -> CONVERGENCE */ /*-----------------------*/ - page = gtk_vbox_new(FALSE, _SPACE); - label = gtk_label_new("CONVERGENCE"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,label); + GUI_PAGE_NOTE(notebook,page,"CONVERGENCE"); /* --- general */ - frame = gtk_frame_new("General"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"General"); /* create a table in the frame*/ - table = gtk_table_new(5, 4, FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,5,4); /* 1st line */ GUI_COMBOBOX_TABLE(table,vasp_gui.prec,"PREC=",0,1,0,1); GUI_COMBOBOX_ADD(vasp_gui.prec,"Normal"); @@ -2951,11 +2913,9 @@ GUI_TOOLTIP(vasp_gui.icharg,"ICHARG: Ch. 6.15 DEFAULT 2\nDetermine how the initi elec_toggle(NULL,NULL); /* --- end frame */ /* --- mixing */ - frame = gtk_frame_new("Mixing"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Mixing"); /* create a table in the frame*/ - table = gtk_table_new(5, 3, FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,5,3); /* 1st line */ GUI_COMBOBOX_TABLE(table,vasp_gui.mixer,"IMIX=",0,1,0,1); GUI_COMBOBOX_ADD(vasp_gui.mixer,"0:NONE"); @@ -3004,11 +2964,9 @@ GUI_TOOLTIP(vasp_gui.wc,"WC: Ch. 6.49 DEFAULT: 1000\nstep weight factor for Broy mixer_toggle(NULL,NULL); /* --- end frame */ /* --- projector */ - frame = gtk_frame_new("Projector"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Projector"); /* create a table in the frame*/ - table = gtk_table_new(5, 4, FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,5,4); /* 1st line */ GUI_COMBOBOX_TABLE(table,vasp_gui.lreal,"LREAL=",0,1,0,1); GUI_COMBOBOX_ADD(vasp_gui.lreal,"Auto"); @@ -3055,15 +3013,11 @@ GUI_TOOLTIP(vasp_gui.ngzf,"NGZF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh gri /*-------------------*/ /* page 2 -> ELECT-I */ /*-------------------*/ - page = gtk_vbox_new(FALSE, _SPACE); - label = gtk_label_new("ELECT-I"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,label); + GUI_PAGE_NOTE(notebook,page,"ELECT-I"); /* --- smearing */ - frame = gtk_frame_new("Smearing"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Smearing"); /* create a table in the frame*/ - table = gtk_table_new(4, 2, FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,4,2); /* 1st line */ GUI_ENTRY_TABLE(table,vasp_gui.ismear,vasp_gui.calc.ismear,"%i","ISMEAR=",0,1,0,1); GUI_TOOLTIP(vasp_gui.ismear,"ISMEAR: Ch. 6.38 DEFAULT: 1\nDetermine how the partial occupations are set.\nIt is advised to change it to ISMEAR=0\nfor semiconducting or insulating materials."); @@ -3080,11 +3034,9 @@ GUI_TOOLTIP(vasp_gui.fermwe,"FERMWE: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 explicitl GUI_TOOLTIP(vasp_gui.fermdo,"FERDO: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 and ISPIN=2 sets\noccupancy for down spin of each band."); /* --- end frame */ /* --- spin */ - frame = gtk_frame_new("Spin"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Spin"); /* create a table in the frame*/ - table = gtk_table_new(5, 2,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,5,2); /* 1st line */ GUI_CHECK_TABLE(table,button,vasp_gui.calc.ispin,NULL,"SPIN POLARIZED",0,1,0,1);/*not calling anything*/ GUI_TOOLTIP(button,"ISPIN: Ch. 6.12 DEFAULT 1\nSpin polarized calculation sets ISPIN=2."); @@ -3103,11 +3055,9 @@ GUI_TOOLTIP(vasp_gui.magmom,"MAGMOM: Ch. 6.13 DEFAULT: NIONS\nSets the initial m GUI_TOOLTIP(vasp_gui.saxis,"SAXIS: Ch. 6.68.2 DEFAULT -\nSets the quantisation axis for spin.\nThe default is SAXIS = eps 0 1\nwhere eps is a small quantity."); /* --- end frame */ /* --- exchange correlation */ - frame = gtk_frame_new("Exchange Correlation"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Exchange Correlation"); /* create a table in the frame*/ - table = gtk_table_new(5, 5,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,5,5); /* 1st line */ GUI_COMBOBOX_TABLE(table,vasp_gui.gga,"GGA=",0,1,0,1); GUI_COMBOBOX_ADD(vasp_gui.gga,"91:PW91"); @@ -3172,11 +3122,9 @@ GUI_TOOLTIP(vasp_gui.ldauj,"LDAUJ: Ch. 6.70 DEFAULT: -\nSets effective on-site E ldau_toggle(NULL,NULL);/*initialize TODO: move to end*/ /* --- end frame */ /* --- dipole */ - frame = gtk_frame_new("Dipole"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Dipole"); /* create a table in the frame*/ - table = gtk_table_new(2, 5,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,2,5); /* 1st line */ GUI_COMBOBOX_TABLE(table,vasp_gui.idipol,"IDIPOL=",0,1,0,1); GUI_COMBOBOX_ADD(vasp_gui.idipol,"0:no calcul"); @@ -3219,77 +3167,66 @@ if(vasp_gui.calc.idipol!=VID_0) { /*---------------------*/ /* page 2b -> ELECT-II */ /*---------------------*/ - page = gtk_vbox_new(FALSE, _SPACE); - label = gtk_label_new("ELECT-II"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,label); + GUI_PAGE_NOTE(notebook,page,"ELECT-II"); /* --- DOS */ - frame = gtk_frame_new("Density of States"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Density of States"); /* create a table in the frame*/ - table = gtk_table_new(2, 5, FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,2,5); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.lorbit,"LORBIT=",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.lorbit,"0:PROCAR"); - VASP_COMBOBOX_ADD(vasp_gui.lorbit,"1:lm-PROCAR"); - VASP_COMBOBOX_ADD(vasp_gui.lorbit,"2:phase+lm-PROCAR"); - VASP_COMBOBOX_ADD(vasp_gui.lorbit,"5:PROOUT"); - VASP_COMBOBOX_ADD(vasp_gui.lorbit,"10:PROCAR"); - VASP_COMBOBOX_ADD(vasp_gui.lorbit,"11:lm-PROCAR"); - VASP_COMBOBOX_ADD(vasp_gui.lorbit,"12:phase+lm-PROCAR"); + GUI_COMBOBOX_TABLE(table,vasp_gui.lorbit,"LORBIT=",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.lorbit,"0:PROCAR"); + GUI_COMBOBOX_ADD(vasp_gui.lorbit,"1:lm-PROCAR"); + GUI_COMBOBOX_ADD(vasp_gui.lorbit,"2:phase+lm-PROCAR"); + GUI_COMBOBOX_ADD(vasp_gui.lorbit,"5:PROOUT"); + GUI_COMBOBOX_ADD(vasp_gui.lorbit,"10:PROCAR"); + GUI_COMBOBOX_ADD(vasp_gui.lorbit,"11:lm-PROCAR"); + GUI_COMBOBOX_ADD(vasp_gui.lorbit,"12:phase+lm-PROCAR"); GUI_TOOLTIP(vasp_gui.lorbit,"LORBIT: Ch. 6.34 DEFAULT: 0\nSets the spd- and site projected\nwavefunction character of each band\nand the local partial DOS."); - VASP_ENTRY_TABLE(vasp_gui.nedos,vasp_gui.calc.nedos,"%i","NEDOS=",1,2,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.nedos,vasp_gui.calc.nedos,"%i","NEDOS=",1,2,0,1); GUI_TOOLTIP(vasp_gui.nedos,"NEDOS: Ch. 6.37 DEFAULT: 301\nNumber of points for which DOS is calculated."); - VASP_ENTRY_TABLE(vasp_gui.emin,vasp_gui.calc.emin,"%.2lf","EMIN=",2,3,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.emin,vasp_gui.calc.emin,"%.2lf","EMIN=",2,3,0,1); GUI_TOOLTIP(vasp_gui.emin,"EMIN: Ch. 6.37 DEFAULT: low eig-eps\nSets the smallest energy for which DOS is calculated.\nDefault is lowest Kohn-Sham eigenvalue minus a small quantity."); - VASP_ENTRY_TABLE(vasp_gui.emax,vasp_gui.calc.emax,"%.2lf","EMAX=",3,4,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.emax,vasp_gui.calc.emax,"%.2lf","EMAX=",3,4,0,1); GUI_TOOLTIP(vasp_gui.emax,"EMAX: Ch. 6.37 DEFAULT: high eig+eps\nSets the highest energy for which DOS is calculated.\nDefault is highest Kohn-Sham eigenvalue plus a small quantity."); - VASP_ENTRY_TABLE(vasp_gui.efermi,vasp_gui.calc.efermi,"%.2lf","EFERMI=",4,5,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.efermi,vasp_gui.calc.efermi,"%.2lf","EFERMI=",4,5,0,1); GUI_TOOLTIP(vasp_gui.efermi,"EFERMI: (secret) DEFAULT: EREF\nSets initial Fermi energy before it is calculated.\nUsually there is no use to change this setting.\nEREF is actually another \"secret\" parameter."); /* 2nd line */ - VASP_LABEL_TABLE("(LORBIT>5) => Req. PAW",0,1,1,2); - VASP_CHECK_TABLE(vasp_gui.have_paw,vasp_gui.calc.have_paw,NULL,"HAVE PAW",1,2,1,2);/*not calling anything*/ + GUI_LEFT_LABEL_TABLE(table,"(LORBIT>5) => Req. PAW",0,1,1,2); + GUI_CHECK_TABLE(table,vasp_gui.have_paw,vasp_gui.calc.have_paw,NULL,"HAVE PAW",1,2,1,2);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.have_paw,"Is set if a PAW POTCAR file is detected."); - gtk_widget_set_sensitive(vasp_gui.have_paw,FALSE);/*just an indication*/ - VASP_TEXT_TABLE(vasp_gui.rwigs,vasp_gui.calc.rwigs,"RWIGS=",2,5,1,2); + GUI_LOCK(vasp_gui.have_paw);/*just an indication*/ + GUI_TEXT_TABLE(table,vasp_gui.rwigs,vasp_gui.calc.rwigs,"RWIGS=",2,5,1,2); GUI_TOOLTIP(vasp_gui.rwigs,"RWIGS: Ch. 6.33 DEFAULT: -\nSets the Wigner Seitz radius for each species.\nDefault value is read from POTCAR."); /* initialize */ -if(vasp_gui.calc.have_paw) VASP_COMBOBOX_SETUP(vasp_gui.lorbit,4,vasp_lorbit_selected); -else VASP_COMBOBOX_SETUP(vasp_gui.lorbit,0,vasp_lorbit_selected); +if(vasp_gui.calc.have_paw) GUI_COMBOBOX_SETUP(vasp_gui.lorbit,4,vasp_lorbit_selected); +else GUI_COMBOBOX_SETUP(vasp_gui.lorbit,0,vasp_lorbit_selected); /* --- end frame */ /* --- Linear Response */ - frame = gtk_frame_new("Linear Response"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Linear Response"); /* create a table in the frame*/ - table = gtk_table_new(1, 5,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,1,5); /* 1st line */ - VASP_CHECK_TABLE(vasp_gui.loptics,vasp_gui.calc.loptics,NULL,"LOPTICS",0,1,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.loptics,vasp_gui.calc.loptics,NULL,"LOPTICS",0,1,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.loptics,"LOPTICS: Ch. 6.72.1 DEFAULT: FALSE\nSwitch frequency dependent dielectric matrix calculation\nover a grid determined by NEDOS.\nIt is advised to increase NEDOS & NBANDS."); - VASP_CHECK_TABLE(vasp_gui.lepsilon,vasp_gui.calc.lepsilon,NULL,"LEPSILON",1,2,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.lepsilon,vasp_gui.calc.lepsilon,NULL,"LEPSILON",1,2,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.lepsilon,"LEPSILON: Ch. 6.72.4 DEFAULT: FALSE\nSwitch dielectric matrix calculation using\ndensity functional perturbation theory.\nConcurrent to LOPTICS, it is not recommended\nto run both at the same time."); - VASP_CHECK_TABLE(vasp_gui.lrpa,vasp_gui.calc.lrpa,NULL,"LRPA",2,3,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.lrpa,vasp_gui.calc.lrpa,NULL,"LRPA",2,3,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.lrpa,"LRPA: Ch. 6.72.5 DEFAULT: FALSE\nSwitch local field effects calculation\non the Hartree level only (no XC)."); - VASP_CHECK_TABLE(vasp_gui.lnabla,vasp_gui.calc.lnabla,NULL,"LNABLA",3,4,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.lnabla,vasp_gui.calc.lnabla,NULL,"LNABLA",3,4,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.lnabla,"LNABLA: Ch. 6.72.3 DEFAULT: FALSE\nSwitch to the simple transversal expressions\nof the frequency dependent dielectric matrix.\nUsually there is no use to change this setting."); - VASP_ENTRY_TABLE(vasp_gui.cshift,vasp_gui.calc.cshift,"%.2lf","CSHIFT=",4,5,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.cshift,vasp_gui.calc.cshift,"%.2lf","CSHIFT=",4,5,0,1); GUI_TOOLTIP(vasp_gui.cshift,"CSHIFT: Ch. 6.72.2 DEFAULT: 0.1\nSets the complex shift \%nu of the Kramers-Kronig\ntransformation of the dielectric function.\nIf CSHIFT is decreased, NEDOS should be increased."); /* --- end frame */ - /*-----------------*/ /* page 3 -> IONIC */ /*-----------------*/ - page = gtk_vbox_new(FALSE, _SPACE); - label = gtk_label_new("IONIC"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,label); + GUI_PAGE_NOTE(notebook,page,"IONIC"); /* --- general */ - frame = gtk_frame_new("General"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"General"); /* create a table in the frame*/ - table = gtk_table_new(2, 5,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,2,5); /* 1st line */ VASP_COMBOBOX_TABLE(vasp_gui.ibrion,"IBRION=",0,1,0,1); VASP_COMBOBOX_ADD(vasp_gui.ibrion,"-1:Nothing"); @@ -3335,11 +3272,9 @@ GUI_TOOLTIP(vasp_gui.nfree,"NFREE: Ch. 6.22 DEFAULT: -\nSets the number of ionic VASP_COMBOBOX_SETUP(vasp_gui.isif,0,vasp_isif_selected); /* --- end frame */ /* --- MD */ - frame = gtk_frame_new("Molecular Dynamics"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Molecular Dynamics"); /* create a table in the frame*/ - table = gtk_table_new(2, 5,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,2,5); /* 1st line */ //multicolumn label label = gtk_label_new("SET IBRION=0 FOR MD"); @@ -3381,11 +3316,9 @@ GUI_TOOLTIP(vasp_gui.apaco,"APACO: Ch. 6.31 DEFAULT: 16\nMax distance (Ang) for } /* --- end frame */ /* --- POSCAR */ - frame = gtk_frame_new("POSCAR & SYMMTERY"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"POSCAR & SYMMTERY"); /* create a table in the frame*/ - table = gtk_table_new(7, 5,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,7,5); /* 1st line */ VASP_COMBOBOX_TABLE(vasp_gui.poscar_free,"DYN:",0,1,0,1); VASP_COMBOBOX_ADD(vasp_gui.poscar_free,"All atom FIXED"); @@ -3509,15 +3442,11 @@ if((vasp_gui.calc.poscar_free==VPF_FIXED)||(vasp_gui.calc.poscar_free==VPF_FREE) /*-------------------*/ /* page 4 -> KPOINTS */ /*-------------------*/ - page = gtk_vbox_new(FALSE, _SPACE); - label = gtk_label_new("KPOINTS"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,label); + GUI_PAGE_NOTE(notebook,page,"KPOINTS"); /* --- from INCAR */ - frame = gtk_frame_new("from INCAR"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"from INCAR"); /* create a table in the frame*/ - table = gtk_table_new(1, 5,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,1,5); /* 1st line */ VASP_ENTRY_TABLE(vasp_gui.ismear_3,vasp_gui.calc.ismear,"%i","ISMEAR=",0,1,0,1); GUI_TOOLTIP(vasp_gui.ismear_3,"ISMEAR: Ch. 6.38 DEFAULT: 1\nDetermine how the partial occupations are set.\nIt is advised to change it to ISMEAR=0\nfor semiconducting or insulating materials."); @@ -3529,11 +3458,9 @@ GUI_TOOLTIP(vasp_gui.kspacing_3,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS fi /*empty: col4*/ /* --- end frame */ /* --- General */ - frame = gtk_frame_new("General"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"General"); /* create a table in the frame*/ - table = gtk_table_new(2, 5,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,2,5); /* 1st line */ VASP_COMBOBOX_TABLE(vasp_gui.kpoints_mode,"GEN:",0,1,0,1); VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Manual Entry"); @@ -3564,11 +3491,9 @@ GUI_TOOLTIP(vasp_gui.kpoints_sy,"In case a grid is used to generate k-points\nTh GUI_TOOLTIP(vasp_gui.kpoints_sz,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 3rd reciprocal lattice component."); /* --- end frame */ /* --- Coordinate */ - vasp_gui.kpoints_coord = gtk_frame_new("Coordinate"); - gtk_box_pack_start(GTK_BOX(page),vasp_gui.kpoints_coord,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,vasp_gui.kpoints_coord,"Coordinate"); /* create a table in the frame*/ - table = gtk_table_new(2, 5,FALSE); - gtk_container_add(GTK_CONTAINER(vasp_gui.kpoints_coord), table); + GUI_TABLE_FRAME(vasp_gui.kpoints_coord,table,2,5); /* 1st line */ VASP_COMBOBOX_TABLE(vasp_gui.kpoints_kpts,"KPOINT:",0,4,0,1); VASP_COMBOBOX_ADD(vasp_gui.kpoints_kpts,"ADD kpoint"); @@ -3593,11 +3518,9 @@ GUI_TOOLTIP(vasp_gui.kpoints_z,"Coordinate of k-point in 3rd component of select GUI_TOOLTIP(vasp_gui.kpoints_w,"Symmetry degeneration weight of k-point.\nSum of all weight does not have to be 1\nbut relative ratio should be respected."); /* --- end frame */ /* --- Tetrahedron */ - vasp_gui.kpoints_tetra = gtk_frame_new("Tetrahedron"); - gtk_box_pack_start(GTK_BOX(page),vasp_gui.kpoints_tetra,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,vasp_gui.kpoints_tetra,"Tetrahedron"); /* create a table in the frame*/ - table = gtk_table_new(3, 6,FALSE); - gtk_container_add(GTK_CONTAINER(vasp_gui.kpoints_tetra), table); + GUI_TABLE_FRAME(vasp_gui.kpoints_tetra,table,3,6); /* 1st line */ VASP_ENTRY_TABLE(vasp_gui.tetra_total,vasp_gui.calc.tetra_total,"%i","TOTAL=",0,1,0,1); GUI_TOOLTIP(vasp_gui.tetra_total,"Total number of tetrahedrons."); @@ -3644,15 +3567,11 @@ GUI_TOOLTIP(vasp_gui.tetra_d,"4th corner of the tetrahedron (D) in k-point index /*------------------*/ /* page 5 -> POTCAR */ /*------------------*/ - page = gtk_vbox_new(FALSE, _SPACE); - label = gtk_label_new("POTCAR"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,label); + GUI_PAGE_NOTE(notebook,page,"POTCAR"); /* --- general */ - frame = gtk_frame_new("General"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"General"); /* create a table in the frame*/ - table = gtk_table_new(2, 1,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,2,1); /* 1st line */ VASP_TEXT_TABLE(vasp_gui.poscar_species,vasp_gui.calc.species_symbols,"SPECIES:",0,1,0,1); gtk_widget_set_sensitive(vasp_gui.poscar_species,FALSE); @@ -3662,11 +3581,9 @@ GUI_TOOLTIP(vasp_gui.poscar_species,"List of atomic symbol of the species\ndetec gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2); /* --- end frame */ /* --- get POTCAR information */ - frame = gtk_frame_new("get POTCAR information"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"get POTCAR information"); /* create a table in the frame*/ - table = gtk_table_new(3, 4,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,3,4); /* 1st line */ /* 2 lines radiobutton */ vbox = gtk_vbox_new(FALSE,0); @@ -3691,11 +3608,9 @@ GUI_TOOLTIP(vasp_gui.species_flavor,"When Using PATH method, for each species a toggle_potcar_file(NULL,NULL); /* --- end frame */ /* --- POTCAR results */ - frame = gtk_frame_new("POTCAR results"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"POTCAR results"); /* create a table in the frame*/ - table = gtk_table_new(2, 2,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,2,2); /* 1st line */ //multicolumn label label = gtk_label_new("DETECTED"); @@ -3712,15 +3627,11 @@ GUI_TOOLTIP(vasp_gui.potcar_species_flavor,"List of the pseudopotential flavors /*----------------*/ /* page 6 -> EXEC */ /*----------------*/ - page = gtk_vbox_new(FALSE, _SPACE); - label = gtk_label_new("EXEC"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook),page,label); + GUI_PAGE_NOTE(notebook,page,"EXEC"); /* --- general */ - frame = gtk_frame_new("General"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"General"); /* create a table in the frame*/ - table = gtk_table_new(3, 6,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,3,6); /* 1st line */ VASP_LABEL_TABLE("VASP EXEC:",0,1,0,1); VASP_TEXT_TABLE(vasp_gui.job_vasp_exe,vasp_gui.calc.job_vasp_exe,"FILE=",1,5,0,1); @@ -3745,11 +3656,9 @@ GUI_TOOLTIP(button,"LVHAR: Ch. 6.54 DEFAULT: FALSE\nIf set the full local potent GUI_TOOLTIP(button,"LELF: Ch 6.55 DEFAULT: FALSE\nIf set the ELFCAR (electron localization function)\nfile is written."); /* --- end frame */ /* --- PARALLEL */ - frame = gtk_frame_new("Parallel Optimization"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Parallel Optimization"); /* create a table in the frame*/ - table = gtk_table_new(2, 6,FALSE); - gtk_container_add(GTK_CONTAINER(frame), table); + GUI_TABLE_FRAME(frame,table,2,6); /* 1st line */ VASP_LABEL_TABLE("MPIRUN:",0,1,0,1); VASP_TEXT_TABLE(vasp_gui.job_mpirun,vasp_gui.calc.job_mpirun,"FILE=",1,5,0,1); @@ -3770,11 +3679,9 @@ GUI_TOOLTIP(button,"LSCALU: Ch. 6.59 DEFAULT: FALSE\nIf set parallel LU decompos GUI_TOOLTIP(button,"LSCALAPACK: Ch. 6.59 DEFAULT: FALSE\nIf set scaLAPACK routines will be used."); /* --- end frame */ /* --- DISTANT */ - frame = gtk_frame_new("Distant calculation"); - gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0); + GUI_FRAME_NOTE(page,frame,"Distant calculation"); /*create a vbox in frame*/ - vbox=gtk_vbox_new(TRUE, 0); - gtk_container_add(GTK_CONTAINER(frame),vbox); + GUI_VBOX_FRAME(frame,vbox); /* 1st line */ VASP_NEW_LINE(); /* 2nd line */ @@ -3796,10 +3703,8 @@ GUI_TOOLTIP(button,"LSCALAPACK: Ch. 6.59 DEFAULT: FALSE\nIf set scaLAPACK routin VASP_NEW_LINE(); /* --- Outside of notebook */ - frame = gtk_frame_new(NULL); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(vasp_gui.window)->vbox), frame, FALSE, FALSE, 0); - vbox = gtk_vbox_new(FALSE, _SPACE); - gtk_container_add(GTK_CONTAINER(frame), vbox); + GUI_FRAME_BOX(GTK_BOX(GTK_DIALOG(vasp_gui.window)->vbox),frame); + GUI_VBOX_FRAME(frame,vbox); /* Action buttons */ vasp_gui.button_save=gui_stock_button(GTK_STOCK_SAVE, save_vasp_calc, NULL, GTK_DIALOG(vasp_gui.window)->action_area); vasp_gui.button_exec=gui_stock_button(GTK_STOCK_EXECUTE, exec_calc, NULL, GTK_DIALOG(vasp_gui.window)->action_area); From 4290b4eed9086eec08084a31683f4aa48f2854e2 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 25 Jul 2018 15:51:12 +0900 Subject: [PATCH 05/56] gui_uspex: prepare unified gui interface V. --- src/gui_defs.h | 12 +-- src/gui_vasp.c | 214 +++++++++++++++++++++++-------------------------- 2 files changed, 109 insertions(+), 117 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index 04e6d06..67c7f13 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -239,12 +239,14 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ }while(0) /*Create a new cell with: - * a boxed button (button_1) of type APPLY connected on click to function (function_1), - * a boxed button (button_2) of type DELETE connected on click to function (function_2).*/ -#define GUI_2BUTTONS_TABLE(table,button_1,button_2,function_1,function_2,l,r,t,b) do{\ + * a boxed button of type APPLY connected on click to a function (function_1), + * a boxed button of type DELETE connected on click to a function (function_2).*/ +#define GUI_2BUTTONS_TABLE(table,function_1,function_2,l,r,t,b) do{\ GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ - button_1 = gui_stock_button(GTK_STOCK_APPLY,function_1,NULL,_hbox);\ - button_2 = gui_stock_button(GTK_STOCK_DELETE,function_2,NULL,_hbox);\ + GtkWidget *_sep;\ + GUI_NEW_SEPARATOR(_hbox,_sep);\ + gui_stock_button(GTK_STOCK_APPLY,function_1,NULL,_hbox);\ + gui_stock_button(GTK_STOCK_DELETE,function_2,NULL,_hbox);\ gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ }while(0) /*left aligned labels*/ diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 4cdf6d5..ce8d2bc 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -3228,48 +3228,48 @@ GUI_TOOLTIP(vasp_gui.cshift,"CSHIFT: Ch. 6.72.2 DEFAULT: 0.1\nSets the complex s /* create a table in the frame*/ GUI_TABLE_FRAME(frame,table,2,5); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.ibrion,"IBRION=",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"-1:Nothing"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"0:Molecular Dynamics"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"1:Quasi-Newton"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"2:Conjugate Gradients"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"3:Damped"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"5:Finite Differences"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"6:Finite Diff. with SYM"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"7:Perturbation Theory"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"8:Pert. Theory with SYM"); - VASP_COMBOBOX_ADD(vasp_gui.ibrion,"44:Transition State"); + GUI_COMBOBOX_TABLE(table,vasp_gui.ibrion,"IBRION=",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"-1:Nothing"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"0:Molecular Dynamics"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"1:Quasi-Newton"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"2:Conjugate Gradients"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"3:Damped"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"5:Finite Differences"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"6:Finite Diff. with SYM"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"7:Perturbation Theory"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"8:Pert. Theory with SYM"); + GUI_COMBOBOX_ADD(vasp_gui.ibrion,"44:Transition State"); GUI_TOOLTIP(vasp_gui.ibrion,"IBRION: Ch. 6.22 DEFAULT -1\nSets the algorithm for the ions motion.\nDefault is IBRION=0 if NSW>1."); - VASP_ENTRY_TABLE(vasp_gui.nsw,vasp_gui.calc.nsw,"%i","NSW=",1,2,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.nsw,vasp_gui.calc.nsw,"%i","NSW=",1,2,0,1); GUI_TOOLTIP(vasp_gui.nsw,"NSW: Ch. 6.20 DEFAULT 0\nSet the maximum number of ionic steps."); - VASP_ENTRY_TABLE(vasp_gui.ediffg,vasp_gui.calc.ediffg,"%.2E","EDIFFG=",2,3,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.ediffg,vasp_gui.calc.ediffg,"%.2E","EDIFFG=",2,3,0,1); GUI_TOOLTIP(vasp_gui.ediffg,"EDIFFG: Ch. 6.19 DEFAULT EDIFF*10\nSets the energy criterion for ending ionic relaxation\n>0 value are for energy difference (eV)\n<0 values are for absolute forces value (eV/Ang)."); - VASP_ENTRY_TABLE(vasp_gui.potim,vasp_gui.calc.potim,"%.4lf","POTIM=",3,4,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.potim,vasp_gui.calc.potim,"%.4lf","POTIM=",3,4,0,1); GUI_TOOLTIP(vasp_gui.potim,"POTIM: Ch. 6.23 DEFAULT 0.5\nFor IBRION=0 (MD) sets time step (fs)\nfor IBRION=1-3 sets force scaling constant."); - VASP_ENTRY_TABLE(vasp_gui.pstress,vasp_gui.calc.pstress,"%.4lf","PSTRESS=",4,5,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.pstress,vasp_gui.calc.pstress,"%.4lf","PSTRESS=",4,5,0,1); GUI_TOOLTIP(vasp_gui.pstress,"PSTRESS: Ch. 6.25 DEFAULT 0\nSets the Pulay stress correction (kBar)\nalso used to set an external pressure."); /* 2nd line */ - VASP_COMBOBOX_TABLE(vasp_gui.isif,"ISIF=",0,1,1,2); - VASP_COMBOBOX_ADD(vasp_gui.isif,"0:F_0_I_0_0"); - VASP_COMBOBOX_ADD(vasp_gui.isif,"1:F_P_I_0_0"); - VASP_COMBOBOX_ADD(vasp_gui.isif,"2:F_S_I_0_0"); - VASP_COMBOBOX_ADD(vasp_gui.isif,"3:F_S_I_S_V"); - VASP_COMBOBOX_ADD(vasp_gui.isif,"4:F_S_I_S_0"); - VASP_COMBOBOX_ADD(vasp_gui.isif,"5:F_S_0_S_0"); - VASP_COMBOBOX_ADD(vasp_gui.isif,"6:F_S_0_S_V"); - VASP_COMBOBOX_ADD(vasp_gui.isif,"7:F_S_0_0_V"); + GUI_COMBOBOX_TABLE(table,vasp_gui.isif,"ISIF=",0,1,1,2); + GUI_COMBOBOX_ADD(vasp_gui.isif,"0:F_0_I_0_0"); + GUI_COMBOBOX_ADD(vasp_gui.isif,"1:F_P_I_0_0"); + GUI_COMBOBOX_ADD(vasp_gui.isif,"2:F_S_I_0_0"); + GUI_COMBOBOX_ADD(vasp_gui.isif,"3:F_S_I_S_V"); + GUI_COMBOBOX_ADD(vasp_gui.isif,"4:F_S_I_S_0"); + GUI_COMBOBOX_ADD(vasp_gui.isif,"5:F_S_0_S_0"); + GUI_COMBOBOX_ADD(vasp_gui.isif,"6:F_S_0_S_V"); + GUI_COMBOBOX_ADD(vasp_gui.isif,"7:F_S_0_0_V"); GUI_TOOLTIP(vasp_gui.isif,"ISIF: Ch. 6.24 DEFAULT 2\nSwitch to calculate F(force) and S(stress)\nand to relax I(ion) S(cell shape) and V(cell voume)\n0 = no calcul/no relaxation P = only total Pressure\nDefault is 0(F_0_I_0_0) if IBRION=0."); - VASP_CHECK_TABLE(vasp_gui.relax_ions,vasp_gui.rions,isif_toggle,"atom positions",1,2,1,2); + GUI_CHECK_TABLE(table,vasp_gui.relax_ions,vasp_gui.rions,isif_toggle,"atom positions",1,2,1,2); GUI_TOOLTIP(vasp_gui.relax_ions,"Switches atomic relaxation.\nUpdates ISIF accordingly (but not IBRION)."); - VASP_CHECK_TABLE(vasp_gui.relax_shape,vasp_gui.rshape,isif_toggle,"cell shape",2,3,1,2); + GUI_CHECK_TABLE(table,vasp_gui.relax_shape,vasp_gui.rshape,isif_toggle,"cell shape",2,3,1,2); GUI_TOOLTIP(vasp_gui.relax_ions,"Switches cell shape relaxation.\nUpdates ISIF accordingly (but not IBRION)."); - VASP_CHECK_TABLE(vasp_gui.relax_volume,vasp_gui.rvolume,isif_toggle,"cell volume",3,4,1,2); + GUI_CHECK_TABLE(table,vasp_gui.relax_volume,vasp_gui.rvolume,isif_toggle,"cell volume",3,4,1,2); GUI_TOOLTIP(vasp_gui.relax_ions,"Switches cell volume relaxation.\nUpdates ISIF accordingly (but not IBRION)."); - VASP_ENTRY_TABLE(vasp_gui.nfree,vasp_gui.calc.nfree,"%i","NFREE=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.nfree,vasp_gui.calc.nfree,"%i","NFREE=",4,5,1,2); GUI_TOOLTIP(vasp_gui.nfree,"NFREE: Ch. 6.22 DEFAULT: -\nSets the number of ionic steps kept in history\nfor IBRION=1 Quasi-Newton algorithm.\nFor finite difference IBRION=5-6 NFREE\nsets the number of displacement/direction/atom."); /* initialize */ - VASP_COMBOBOX_SETUP(vasp_gui.ibrion,0,vasp_ibrion_selected); - VASP_COMBOBOX_SETUP(vasp_gui.isif,0,vasp_isif_selected); + GUI_COMBOBOX_SETUP(vasp_gui.ibrion,0,vasp_ibrion_selected); + GUI_COMBOBOX_SETUP(vasp_gui.isif,0,vasp_isif_selected); /* --- end frame */ /* --- MD */ GUI_FRAME_NOTE(page,frame,"Molecular Dynamics"); @@ -3277,42 +3277,41 @@ GUI_TOOLTIP(vasp_gui.nfree,"NFREE: Ch. 6.22 DEFAULT: -\nSets the number of ionic GUI_TABLE_FRAME(frame,table,2,5); /* 1st line */ //multicolumn label - label = gtk_label_new("SET IBRION=0 FOR MD"); - gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,2); - VASP_ENTRY_TABLE(vasp_gui.tebeg,vasp_gui.calc.tebeg,"%.1lf","TEBEG=",1,2,0,1); + GUI_LABEL_TABLE(table,"SET IBRION=0 FOR MD",0,1,0,2); + GUI_ENTRY_TABLE(table,vasp_gui.tebeg,vasp_gui.calc.tebeg,"%.1lf","TEBEG=",1,2,0,1); GUI_TOOLTIP(vasp_gui.tebeg,"TEBEG: Ch. 6.29 DEFAULT: 0\nSets the start temperature of MD run.\nTo be corrected by (Nion-1)/Nion."); - VASP_ENTRY_TABLE(vasp_gui.teend,vasp_gui.calc.teend,"%.1lf","TEEND=",2,3,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.teend,vasp_gui.calc.teend,"%.1lf","TEEND=",2,3,0,1); GUI_TOOLTIP(vasp_gui.teend,"TEEND: Ch. 6.29 DEFAULT: TEBEG\nSets the end temperature of MD run.\nTo be corrected by (Nion-1)/Nion."); - VASP_ENTRY_TABLE(vasp_gui.smass,vasp_gui.calc.smass,"%.1lf","SMASS=",3,4,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.smass,vasp_gui.calc.smass,"%.1lf","SMASS=",3,4,0,1); GUI_TOOLTIP(vasp_gui.smass,"SMASS: Ch. 6.30 DEFAULT 0\nControls the velocities during MD.\nFor IBRION=3 SMASS is used as a damping factor."); /*empty: col4*/ /* 2nd line */ /*occ: col0*/ - VASP_ENTRY_TABLE(vasp_gui.nblock,vasp_gui.calc.nblock,"%i","NBLOCK=",1,2,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.nblock,vasp_gui.calc.nblock,"%i","NBLOCK=",1,2,1,2); GUI_TOOLTIP(vasp_gui.nblock,"NBLOCK: Ch. 6.21 DEFAULT: 1\nSets number of steps after which DOS/pair correlation\nfunction are calculated, and XDATCAR updated.\nFor SMASS=-1 kinetic energy is scaled every NBLOCK."); - VASP_ENTRY_TABLE(vasp_gui.kblock,vasp_gui.calc.kblock,"%i","KBLOCK=",2,3,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kblock,vasp_gui.calc.kblock,"%i","KBLOCK=",2,3,1,2); GUI_TOOLTIP(vasp_gui.kblock,"KBLOCK: Ch. 6.21 DEFAULT: NSW\nAfter KBLOCK*NBLOCK iterations DOS and\naverage pair correlation function is written\nto DOSCAR and PCDAT, respectively."); - VASP_ENTRY_TABLE(vasp_gui.npaco,vasp_gui.calc.npaco,"%i","NPACO=",3,4,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.npaco,vasp_gui.calc.npaco,"%i","NPACO=",3,4,1,2); GUI_TOOLTIP(vasp_gui.npaco,"NPACO Ch. 6.31 DEFAULT: 256\nNumber of slots of pair correlation function."); - VASP_ENTRY_TABLE(vasp_gui.apaco,vasp_gui.calc.apaco,"%.4lf","APACO=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.apaco,vasp_gui.calc.apaco,"%.4lf","APACO=",4,5,1,2); GUI_TOOLTIP(vasp_gui.apaco,"APACO: Ch. 6.31 DEFAULT: 16\nMax distance (Ang) for calculation\nof pair correlation function."); /* initialize sensitive widget*/ if (vasp_gui.calc.ibrion==0) {/*selecting MD enable molecular dynamics settings*/ - gtk_widget_set_sensitive(vasp_gui.tebeg,TRUE); - gtk_widget_set_sensitive(vasp_gui.teend,TRUE); - gtk_widget_set_sensitive(vasp_gui.smass,TRUE); - gtk_widget_set_sensitive(vasp_gui.nblock,TRUE); - gtk_widget_set_sensitive(vasp_gui.kblock,TRUE); - gtk_widget_set_sensitive(vasp_gui.npaco,TRUE); - gtk_widget_set_sensitive(vasp_gui.apaco,TRUE); + GUI_UNLOCK(vasp_gui.tebeg); + GUI_UNLOCK(vasp_gui.teend); + GUI_UNLOCK(vasp_gui.smass); + GUI_UNLOCK(vasp_gui.nblock); + GUI_UNLOCK(vasp_gui.kblock); + GUI_UNLOCK(vasp_gui.npaco); + GUI_UNLOCK(vasp_gui.apaco); }else{ - gtk_widget_set_sensitive(vasp_gui.tebeg,FALSE); - gtk_widget_set_sensitive(vasp_gui.teend,FALSE); - gtk_widget_set_sensitive(vasp_gui.smass,FALSE); - gtk_widget_set_sensitive(vasp_gui.nblock,FALSE); - gtk_widget_set_sensitive(vasp_gui.kblock,FALSE); - gtk_widget_set_sensitive(vasp_gui.npaco,FALSE); - gtk_widget_set_sensitive(vasp_gui.apaco,FALSE); + GUI_LOCK(vasp_gui.tebeg); + GUI_LOCK(vasp_gui.teend); + GUI_LOCK(vasp_gui.smass); + GUI_LOCK(vasp_gui.nblock); + GUI_LOCK(vasp_gui.kblock); + GUI_LOCK(vasp_gui.npaco); + GUI_LOCK(vasp_gui.apaco); } /* --- end frame */ /* --- POSCAR */ @@ -3320,109 +3319,101 @@ GUI_TOOLTIP(vasp_gui.apaco,"APACO: Ch. 6.31 DEFAULT: 16\nMax distance (Ang) for /* create a table in the frame*/ GUI_TABLE_FRAME(frame,table,7,5); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.poscar_free,"DYN:",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.poscar_free,"All atom FIXED"); - VASP_COMBOBOX_ADD(vasp_gui.poscar_free,"All atom FREE"); - VASP_COMBOBOX_ADD(vasp_gui.poscar_free,"Manual selection"); + GUI_COMBOBOX_TABLE(table,vasp_gui.poscar_free,"DYN:",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.poscar_free,"All atom FIXED"); + GUI_COMBOBOX_ADD(vasp_gui.poscar_free,"All atom FREE"); + GUI_COMBOBOX_ADD(vasp_gui.poscar_free,"Manual selection"); GUI_TOOLTIP(vasp_gui.poscar_free,"Set position tags to \"F F F\" (FIXED)\n\"T T T\" (FREE) or user modifications."); - VASP_CHECK_TABLE(button,vasp_gui.calc.poscar_sd,toggle_poscar_sd,"Sel. Dynamics",1,2,0,1); + GUI_CHECK_TABLE(table,button,vasp_gui.calc.poscar_sd,toggle_poscar_sd,"Sel. Dynamics",1,2,0,1); GUI_TOOLTIP(button,"Allow use of tags for ion motion (Ch. 5.7)."); - VASP_ENTRY_TABLE(vasp_gui.isym,vasp_gui.calc.isym,"%i","ISYM=",2,3,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.isym,vasp_gui.calc.isym,"%i","ISYM=",2,3,0,1); GUI_TOOLTIP(vasp_gui.isym,"ISYM: Ch. 6.27 DEFAULT 2\nSwitch symmetry method (0=OFF)\nDefault is 1 for ultrasoft, 2 for PAW PP."); - VASP_ENTRY_TABLE(vasp_gui.sym_prec,vasp_gui.calc.sym_prec,"%.2lE","_PREC=",3,4,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.sym_prec,vasp_gui.calc.sym_prec,"%.2lE","_PREC=",3,4,0,1); GUI_TOOLTIP(vasp_gui.sym_prec,"SYMPREC: Ch. 6.27 DEFAULT 10^-5\nSets the accuracy of ion positions\nin determining the system symmetry."); - VASP_ENTRY_TABLE(vasp_gui.poscar_a0,vasp_gui.calc.poscar_a0,"%.4lf","A0=",4,5,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_a0,vasp_gui.calc.poscar_a0,"%.4lf","A0=",4,5,0,1); GUI_TOOLTIP(vasp_gui.poscar_a0,"Lattice parameter (Ch. 5.7)\nSets the lattice constant (Ang.) parameter\nevery lattice vector will be scaled with."); /* 2nd line */ /*empty: col0 (TODO: SUPERCELL)*/ - VASP_CHECK_TABLE(vasp_gui.poscar_direct,vasp_gui.calc.poscar_direct,toggle_poscar_direct,"Direct Coord.",1,2,1,2); + GUI_CHECK_TABLE(table,vasp_gui.poscar_direct,vasp_gui.calc.poscar_direct,toggle_poscar_direct,"Direct Coord.",1,2,1,2); GUI_TOOLTIP(vasp_gui.poscar_direct,"Sets whether ions positions are given\nin direct lattice or cartesian coordinate."); - VASP_ENTRY_TABLE(vasp_gui.poscar_ux,vasp_gui.calc.poscar_ux,"%.4lf","UX=",2,3,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_ux,vasp_gui.calc.poscar_ux,"%.4lf","UX=",2,3,1,2); GUI_TOOLTIP(vasp_gui.poscar_ux,"First lattice vector x component."); - VASP_ENTRY_TABLE(vasp_gui.poscar_uy,vasp_gui.calc.poscar_uy,"%.4lf","UY=",3,4,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_uy,vasp_gui.calc.poscar_uy,"%.4lf","UY=",3,4,1,2); GUI_TOOLTIP(vasp_gui.poscar_uy,"First lattice vector y component."); - VASP_ENTRY_TABLE(vasp_gui.poscar_uz,vasp_gui.calc.poscar_uz,"%.4lf","UZ=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_uz,vasp_gui.calc.poscar_uz,"%.4lf","UZ=",4,5,1,2); GUI_TOOLTIP(vasp_gui.poscar_uz,"First lattice vector z component."); /* 3rd line */ /*empty: col0 (TODO: -X)*/ /*empty: col1 (TODO: +X)*/ - VASP_ENTRY_TABLE(vasp_gui.poscar_vx,vasp_gui.calc.poscar_vx,"%.4lf","VX=",2,3,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_vx,vasp_gui.calc.poscar_vx,"%.4lf","VX=",2,3,2,3); GUI_TOOLTIP(vasp_gui.poscar_vx,"Second lattice vector x component."); - VASP_ENTRY_TABLE(vasp_gui.poscar_vy,vasp_gui.calc.poscar_vy,"%.4lf","VY=",3,4,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_vy,vasp_gui.calc.poscar_vy,"%.4lf","VY=",3,4,2,3); GUI_TOOLTIP(vasp_gui.poscar_vy,"Second lattice vector y component."); - VASP_ENTRY_TABLE(vasp_gui.poscar_vz,vasp_gui.calc.poscar_vz,"%.4lf","VZ=",4,5,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_vz,vasp_gui.calc.poscar_vz,"%.4lf","VZ=",4,5,2,3); GUI_TOOLTIP(vasp_gui.poscar_vz,"Second lattice vector z component."); /* 4th line */ /*empty: col0 (TODO: -Y)*/ /*empty: col1 (TODO: +Y)*/ - VASP_ENTRY_TABLE(vasp_gui.poscar_wx,vasp_gui.calc.poscar_wx,"%.4lf","WX=",2,3,3,4); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_wx,vasp_gui.calc.poscar_wx,"%.4lf","WX=",2,3,3,4); GUI_TOOLTIP(vasp_gui.poscar_wx,"Third lattice vector x component."); - VASP_ENTRY_TABLE(vasp_gui.poscar_wy,vasp_gui.calc.poscar_wy,"%.4lf","WY=",3,4,3,4); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_wy,vasp_gui.calc.poscar_wy,"%.4lf","WY=",3,4,3,4); GUI_TOOLTIP(vasp_gui.poscar_wy,"Third lattice vector y component."); - VASP_ENTRY_TABLE(vasp_gui.poscar_wz,vasp_gui.calc.poscar_wz,"%.4lf","WZ=",4,5,3,4); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_wz,vasp_gui.calc.poscar_wz,"%.4lf","WZ=",4,5,3,4); GUI_TOOLTIP(vasp_gui.poscar_wz,"Third lattice vector z component."); /* 5th line */ /*empty: col0 (TODO: -Z)*/ /*empty: col1 (TODO: +Z)*/ - VASP_CHECK_TABLE(vasp_gui.poscar_tx,vasp_gui.calc.poscar_tx,NULL,"TX",2,3,4,5);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.poscar_tx,vasp_gui.calc.poscar_tx,NULL,"TX",2,3,4,5);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin first lattice coordinate."); - VASP_CHECK_TABLE(vasp_gui.poscar_ty,vasp_gui.calc.poscar_ty,NULL,"TY",3,4,4,5);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.poscar_ty,vasp_gui.calc.poscar_ty,NULL,"TY",3,4,4,5);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin second lattice coordinate."); - VASP_CHECK_TABLE(vasp_gui.poscar_tz,vasp_gui.calc.poscar_tz,NULL,"TZ",4,5,4,5);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.poscar_tz,vasp_gui.calc.poscar_tz,NULL,"TZ",4,5,4,5);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin third lattice coordinate."); /* 6th line */ - /*this combo is special and should be explicitely defined*/ - hbox = gtk_hbox_new(FALSE, 0); - label = gtk_label_new("ATOMS:"); - gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0); - vasp_gui.poscar_atoms = gtk_combo_box_text_new_with_entry();/*gtkcombo replacement*/ - gtk_entry_set_editable(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(vasp_gui.poscar_atoms))), FALSE);/*supposed to be simple?*/ - idx=0; - for (list2=data->cores ; list2 ; list2=g_slist_next(list2)){ + /*NEW: rewrite of ATOM list combobox*/ + GUI_COMBOBOX_TABLE(table,vasp_gui.poscar_atoms,"ATOMS:",0,4,5,6); + idx=0; + for (list2=data->cores ; list2 ; list2=g_slist_next(list2)){ gchar sym[3]; - core=list2->data; + core=list2->data; sym[0]=core->atom_label[0]; if(g_ascii_islower(core->atom_label[1])) sym[1]=core->atom_label[1]; else sym[1]='\0'; sym[2]='\0'; - if(vasp_gui.calc.poscar_free==VPF_FIXED) -gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (vasp_gui.poscar_atoms),g_strdup_printf("%.8lf %.8lf %.8lf F F F ! atom: %i (%s)", - core->x[0],core->x[1],core->x[2],idx,sym)); - else -gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (vasp_gui.poscar_atoms),g_strdup_printf("%.8lf %.8lf %.8lf T T T ! atom: %i (%s)", - core->x[0],core->x[1],core->x[2],idx,sym)); - idx++; - } -vasp_gui.calc.atoms_total=idx; - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT (vasp_gui.poscar_atoms),"ADD atom"); - gtk_box_pack_start(GTK_BOX(hbox),vasp_gui.poscar_atoms,TRUE,TRUE,0); - gtk_table_attach_defaults(GTK_TABLE(table),hbox,0,4,5,6); - g_signal_connect(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),"changed",GTK_SIGNAL_FUNC(vasp_poscar_atoms_selected),data); + if(vasp_gui.calc.poscar_free==VPF_FIXED){ + GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms, + g_strdup_printf("%.8lf %.8lf %.8lf F F F ! atom: %i (%s)",core->x[0],core->x[1],core->x[2],idx,sym)); + }else{ + GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms, + g_strdup_printf("%.8lf %.8lf %.8lf T T T ! atom: %i (%s)",core->x[0],core->x[1],core->x[2],idx,sym)); + } + idx++; + } + vasp_gui.calc.atoms_total=idx; + GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms,"ADD atom"); + GUI_COMBOBOX_SETUP(vasp_gui.poscar_atoms,idx,vasp_poscar_atoms_selected); + /*this combo is special and should be explicitely defined*/ GUI_TOOLTIP(vasp_gui.poscar_atoms,"Atoms positions in POSCAR format."); /*2 buttons*/ - hbox = gtk_hbox_new(FALSE, 0); - VASP_NEW_SEPARATOR(); - gui_stock_button(GTK_STOCK_APPLY,vasp_atom_modified,NULL,hbox); - gui_stock_button(GTK_STOCK_DELETE,vasp_atom_delete,NULL,hbox); - gtk_table_attach_defaults(GTK_TABLE(table),hbox,4,5,5,6); + GUI_2BUTTONS_TABLE(table,vasp_atom_modified,vasp_atom_delete,4,5,5,6); /* 7th line */ - VASP_ENTRY_TABLE(vasp_gui.poscar_index,vasp_gui.calc.poscar_index,"%i","INDEX:",0,1,6,7); - gtk_widget_set_sensitive(vasp_gui.poscar_index,FALSE);/*<- is changed only by selecting poscar_atoms*/ + GUI_ENTRY_TABLE(table,vasp_gui.poscar_index,vasp_gui.calc.poscar_index,"%i","INDEX:",0,1,6,7); + GUI_LOCK(vasp_gui.poscar_index);/*<- is changed only by selecting poscar_atoms*/ GUI_TOOLTIP(vasp_gui.poscar_index,"Atom number (in POSCAR ORDER)."); - VASP_ENTRY_TABLE(vasp_gui.poscar_symbol,vasp_gui.calc.poscar_symbol,"%s","SYMBOL:",1,2,6,7); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_symbol,vasp_gui.calc.poscar_symbol,"%s","SYMBOL:",1,2,6,7); GUI_TOOLTIP(vasp_gui.poscar_index,"Atom symbol (will correspond to POSCAR).\nChanging symbol will change index accordingly."); - VASP_ENTRY_TABLE(vasp_gui.poscar_x,vasp_gui.calc.poscar_x,"%.6lf","X=",2,3,6,7); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_x,vasp_gui.calc.poscar_x,"%.6lf","X=",2,3,6,7); GUI_TOOLTIP(vasp_gui.poscar_x,"atom component X: x in cartesian mode\nand first lattice coordinate in direct mode."); - VASP_ENTRY_TABLE(vasp_gui.poscar_y,vasp_gui.calc.poscar_y,"%.6lf","Y=",3,4,6,7); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_y,vasp_gui.calc.poscar_y,"%.6lf","Y=",3,4,6,7); GUI_TOOLTIP(vasp_gui.poscar_y,"atom component Y: y in cartesian mode\nand second lattice coordinate in direct mode."); - VASP_ENTRY_TABLE(vasp_gui.poscar_z,vasp_gui.calc.poscar_z,"%.6lf","Z=",4,5,6,7); + GUI_ENTRY_TABLE(table,vasp_gui.poscar_z,vasp_gui.calc.poscar_z,"%.6lf","Z=",4,5,6,7); GUI_TOOLTIP(vasp_gui.poscar_z,"atom component Z: z in cartesian mode\nand third lattice coordinate in direct mode."); /* initialize sensitive widget*/ - VASP_COMBOBOX_SETUP(vasp_gui.poscar_free,1,vasp_poscar_free_selected); + GUI_COMBOBOX_SETUP(vasp_gui.poscar_free,1,vasp_poscar_free_selected); if((vasp_gui.calc.poscar_free==VPF_FIXED)||(vasp_gui.calc.poscar_free==VPF_FREE)){ - gtk_widget_set_sensitive(vasp_gui.poscar_tx,FALSE); - gtk_widget_set_sensitive(vasp_gui.poscar_ty,FALSE); - gtk_widget_set_sensitive(vasp_gui.poscar_tz,FALSE); + GUI_LOCK(vasp_gui.poscar_tx); + GUI_LOCK(vasp_gui.poscar_ty); + GUI_LOCK(vasp_gui.poscar_tz); if(vasp_gui.calc.poscar_free==VPF_FIXED){ vasp_gui.calc.poscar_tx=FALSE; vasp_gui.calc.poscar_ty=FALSE; @@ -3435,7 +3426,6 @@ if((vasp_gui.calc.poscar_free==VPF_FIXED)||(vasp_gui.calc.poscar_free==VPF_FREE) } /* (re)initialize */ toggle_poscar_sd(NULL,NULL); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx);/*sets "ADD atom" as active*/ vasp_poscar_free_selected(vasp_gui.poscar_free,NULL); /* --- end frame */ From 3a23cbc5ffb67569a9658000bd4afba092c854a2 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 25 Jul 2018 18:59:55 +0900 Subject: [PATCH 06/56] gui_uspex: prepare unified gui interface VI. --- src/gui_defs.h | 65 ++++++- src/gui_vasp.c | 496 ++++++++++++++++++++++++------------------------- 2 files changed, 297 insertions(+), 264 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index 67c7f13..1aaf2db 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -92,7 +92,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ tv = gtk_text_view_new();\ tv_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(tv));\ gtk_text_view_set_editable(GTK_TEXT_VIEW(tv),FALSE);\ - GUI_LOCK(tv);\ + gtk_widget_set_sensitive(tv,FALSE);\ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(_absurd),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);\ gtk_container_add(GTK_CONTAINER(_absurd),tv);\ gtk_container_set_border_width(GTK_CONTAINER(_absurd),1);\ @@ -112,6 +112,10 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ frame = gtk_frame_new(caption);\ gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0);\ }while(0) +/*Connect a switch-page even of a notebook (notebook) to a function (function) passing data (data).*/ +#define GUI_PAGE_CHANGE(notebook,function,data) do{\ + g_signal_connect(GTK_NOTEBOOK(notebook),"switch-page",GTK_SIGNAL_FUNC(function),data);\ +}while(0) /*******************/ /* FRAME INTERFACE */ /*******************/ @@ -220,6 +224,11 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ gtk_combo_box_set_active(GTK_COMBO_BOX(combobox),default_value);\ if((function)!=NULL) g_signal_connect(GTK_COMBO_BOX_TEXT(combobox),"changed",GTK_SIGNAL_FUNC(function),data);\ }while(0) +/*Only set a default value (default_value) for the combobox (combobox). + * Can be call anytime, and is equivalent to GUI_COMBOBOX_SETUP(combobox,default_value,NULL).*/ +#define GUI_COMBOBOX_SET(combobox,default_value) do{\ + gtk_combo_box_set_active(GTK_COMBO_BOX(combobox),default_value);\ +}while(0) /*Create a new cell with: * a boxed spin button, which default value is 1 and interval is [1,100], and labeled with text ("caption"). * Due to limitation of GTK, value has to be of double type and not integer (event though it make little sense).*/ @@ -232,11 +241,18 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ gtk_spin_button_set_range(GTK_SPIN_BUTTON(spin),min,max);\ }while(0) /*Create a new cell with: - * a button (not boxed!) of type (type) connected on click to function (function).*/ -#define GUI_BUTTON_TABLE(table,button,type,function,l,r,t,b) do{\ - button=gtk_button_new_from_stock(type);\ + * an open button (button) connected on click to function (function).*/ +#define GUI_OPEN_BUTTON_TABLE(table,button,function,l,r,t,b) do{\ + button=gtk_button_new_from_stock(GTK_STOCK_OPEN);\ + gtk_table_attach_defaults(GTK_TABLE(table),button,l,r,t,b);\ + g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ +}while(0) +/*Create a new cell with: + * an apply button (button) connected on click to function (function).*/ +#define GUI_APPLY_BUTTON_TABLE(table,button,function,l,r,t,b) do{\ + button=gtk_button_new_from_stock(GTK_STOCK_APPLY);\ gtk_table_attach_defaults(GTK_TABLE(table),button,l,r,t,b);\ - g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ + g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ }while(0) /*Create a new cell with: * a boxed button of type APPLY connected on click to a function (function_1), @@ -262,6 +278,16 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ GUI_NEW_SEPARATOR(_hbox,_separator);\ gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ }while(0) +/*Create a new cell with: + * a radio button (radio_1) with caption ("caption_1") connected to function (pointer_1) + * a radio button (radio_2) with caption ("caption_2") connected to function (pointer_2)*/ +#define GUI_2RADIO_TABLE(table,radio_1,caption_1,pointer_1,radio_2,caption_2,pointer_2,l,r,t,b) do{\ + GtkWidget *_vbox = gtk_vbox_new(FALSE,0);\ + new_radio_group(0,_vbox,FF);\ + radio_1 = add_radio_button(caption_1,(gpointer)pointer_1,NULL);\ + radio_2 = add_radio_button(caption_2,(gpointer)pointer_2,NULL);\ + gtk_table_attach_defaults(GTK_TABLE(table),_vbox,l,r,t,b);\ +}while(0) /********************/ /* GENERAL COMMANDS */ /********************/ @@ -269,10 +295,31 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_TOOLTIP(widget,text) gtk_widget_set_tooltip_text(widget,text) /*set the entry (entry) text ("text")*/ #define GUI_ENTRY_TEXT(entry,text) gtk_entry_set_text(GTK_ENTRY(entry),text); +/*connect entry (entry) on change with the function (function) passing data (data).*/ +#define GUI_ENTRY_CHANGE(entry,function,data) g_signal_connect(GTK_OBJECT(GTK_ENTRY(entry)),"changed",GTK_SIGNAL_FUNC(function),data) /*set sensitivity of a widget*/ #define GUI_LOCK(widget) gtk_widget_set_sensitive(widget,FALSE) #define GUI_UNLOCK(widget) gtk_widget_set_sensitive(widget,TRUE) - - - - +/*set a toggle button (button) ON and OFF*/ +#define GUI_TOGGLE_ON(button) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),TRUE) +#define GUI_TOGGLE_OFF(button) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),FALSE) +/*insert a frame (frame) in a dialog (window) using an implicit vertical box.*/ +#define GUI_FRAME_WINDOW(window,frame) do{\ + GUI_FRAME_BOX(GTK_DIALOG(window)->vbox,frame);\ +}while(0) +/*add a save action button (button) connected to function (function) passing data (data) on the dialog (window).*/ +#define GUI_SAVE_ACTION(window,button,function,data) do{\ + button=gui_stock_button(GTK_STOCK_SAVE,function,data,GTK_DIALOG(window)->action_area);\ +}while(0) +/*add an execute action button (button) connected to function (function) passing data (data) on the dialog (window).*/ +#define GUI_EXEC_ACTION(window,button,function,data) do{\ + button=gui_stock_button(GTK_STOCK_EXECUTE,function,data,GTK_DIALOG(window)->action_area);\ +}while(0) +/*add a close action button (button) connected to function (function) passing data (data) on the dialog (window).*/ +#define GUI_CLOSE_ACTION(window,button,function,data) do{\ + button=gui_stock_button(GTK_STOCK_CLOSE,function,data,GTK_DIALOG(window)->action_area);\ +}while(0) +/*display the dialog (window).*/ +#define GUI_SHOW(window) do{\ + gtk_widget_show_all(window);\ +}while(0) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index ce8d2bc..02027c1 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -781,14 +781,14 @@ void vasp_prec_selected(GtkWidget *w, struct model_pak *model){ void prec_toggle(GtkWidget *w, GtkWidget *box){ if(!(vasp_gui.calc.use_prec)){ /*switch to manual values*/ - gtk_widget_set_sensitive(vasp_gui.encut,TRUE); - gtk_widget_set_sensitive(vasp_gui.enaug,TRUE); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.encut),g_strdup_printf("%.2lf",vasp_gui.calc.encut)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.enaug),g_strdup_printf("%.2lf",vasp_gui.calc.enaug)); + GUI_UNLOCK(vasp_gui.encut); + GUI_UNLOCK(vasp_gui.enaug); + GUI_ENTRY_TEXT(vasp_gui.encut,g_strdup_printf("%.2lf",vasp_gui.calc.encut)); + GUI_ENTRY_TEXT(vasp_gui.enaug,g_strdup_printf("%.2lf",vasp_gui.calc.enaug)); }else{ /*switch to automatic values*/ - gtk_widget_set_sensitive(vasp_gui.encut,FALSE); - gtk_widget_set_sensitive(vasp_gui.enaug,FALSE); + GUI_LOCK(vasp_gui.encut); + GUI_LOCK(vasp_gui.enaug); } @@ -798,11 +798,11 @@ void prec_toggle(GtkWidget *w, GtkWidget *box){ /******************/ void vasp_algo_selected(GtkWidget *w, struct model_pak *model){ const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gtk_widget_set_sensitive(vasp_gui.ialgo,FALSE); + GUI_LOCK(vasp_gui.ialgo); switch(index){ case 1://USE_IALGO vasp_gui.calc.algo=VA_IALGO; - gtk_widget_set_sensitive(vasp_gui.ialgo,TRUE); + GUI_UNLOCK(vasp_gui.ialgo); break; case 2://VERYFAST vasp_gui.calc.algo=VA_VERYFAST;break; @@ -876,23 +876,23 @@ void vasp_ialgo_selected(GtkWidget *w, struct model_pak *model){ void elec_toggle(GtkWidget *w, GtkWidget *box){ if(!(vasp_gui.calc.auto_elec)){ /*switch to manual values*/ - gtk_widget_set_sensitive(vasp_gui.nsim,TRUE); - gtk_widget_set_sensitive(vasp_gui.vtime,TRUE); - gtk_widget_set_sensitive(vasp_gui.nbands,TRUE); - gtk_widget_set_sensitive(vasp_gui.nelect,TRUE); - gtk_widget_set_sensitive(vasp_gui.iwavpr,TRUE); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nsim),g_strdup_printf("%i",vasp_gui.calc.nsim)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.vtime),g_strdup_printf("%.4lf",vasp_gui.calc.vtime)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nbands),g_strdup_printf("%i",vasp_gui.calc.nbands)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nelect),g_strdup_printf("%.4lf",vasp_gui.calc.nelect)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.iwavpr),g_strdup_printf("%i",vasp_gui.calc.iwavpr)); + GUI_UNLOCK(vasp_gui.nsim); + GUI_UNLOCK(vasp_gui.vtime); + GUI_UNLOCK(vasp_gui.nbands); + GUI_UNLOCK(vasp_gui.nelect); + GUI_UNLOCK(vasp_gui.iwavpr); + GUI_ENTRY_TEXT(vasp_gui.nsim,g_strdup_printf("%i",vasp_gui.calc.nsim)); + GUI_ENTRY_TEXT(vasp_gui.vtime,g_strdup_printf("%.4lf",vasp_gui.calc.vtime)); + GUI_ENTRY_TEXT(vasp_gui.nbands,g_strdup_printf("%i",vasp_gui.calc.nbands)); + GUI_ENTRY_TEXT(vasp_gui.nelect,g_strdup_printf("%.4lf",vasp_gui.calc.nelect)); + GUI_ENTRY_TEXT(vasp_gui.iwavpr,g_strdup_printf("%i",vasp_gui.calc.iwavpr)); }else{ /*switch to automatic values*/ - gtk_widget_set_sensitive(vasp_gui.nsim,FALSE); - gtk_widget_set_sensitive(vasp_gui.vtime,FALSE); - gtk_widget_set_sensitive(vasp_gui.nbands,FALSE); - gtk_widget_set_sensitive(vasp_gui.nelect,FALSE); - gtk_widget_set_sensitive(vasp_gui.iwavpr,FALSE); + GUI_LOCK(vasp_gui.nsim); + GUI_LOCK(vasp_gui.vtime); + GUI_LOCK(vasp_gui.nbands); + GUI_LOCK(vasp_gui.nelect); + GUI_LOCK(vasp_gui.iwavpr); } } /*******************/ @@ -918,26 +918,26 @@ void vasp_lreal_selected(GtkWidget *w, struct model_pak *model){ void grid_toggle(GtkWidget *w, GtkWidget *box){ if(!(vasp_gui.calc.auto_grid)){ /*switch to manual values*/ - gtk_widget_set_sensitive(vasp_gui.ngx,TRUE); - gtk_widget_set_sensitive(vasp_gui.ngy,TRUE); - gtk_widget_set_sensitive(vasp_gui.ngz,TRUE); - gtk_widget_set_sensitive(vasp_gui.ngxf,TRUE); - gtk_widget_set_sensitive(vasp_gui.ngyf,TRUE); - gtk_widget_set_sensitive(vasp_gui.ngzf,TRUE); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngx),g_strdup_printf("%i",vasp_gui.calc.ngx)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngy),g_strdup_printf("%i",vasp_gui.calc.ngy)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngz),g_strdup_printf("%i",vasp_gui.calc.ngz)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngxf),g_strdup_printf("%i",vasp_gui.calc.ngxf)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngyf),g_strdup_printf("%i",vasp_gui.calc.ngyf)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngzf),g_strdup_printf("%i",vasp_gui.calc.ngzf)); + GUI_UNLOCK(vasp_gui.ngx); + GUI_UNLOCK(vasp_gui.ngy); + GUI_UNLOCK(vasp_gui.ngz); + GUI_UNLOCK(vasp_gui.ngxf); + GUI_UNLOCK(vasp_gui.ngyf); + GUI_UNLOCK(vasp_gui.ngzf); + GUI_ENTRY_TEXT(vasp_gui.ngx,g_strdup_printf("%i",vasp_gui.calc.ngx)); + GUI_ENTRY_TEXT(vasp_gui.ngy,g_strdup_printf("%i",vasp_gui.calc.ngy)); + GUI_ENTRY_TEXT(vasp_gui.ngz,g_strdup_printf("%i",vasp_gui.calc.ngz)); + GUI_ENTRY_TEXT(vasp_gui.ngxf,g_strdup_printf("%i",vasp_gui.calc.ngxf)); + GUI_ENTRY_TEXT(vasp_gui.ngyf,g_strdup_printf("%i",vasp_gui.calc.ngyf)); + GUI_ENTRY_TEXT(vasp_gui.ngzf,g_strdup_printf("%i",vasp_gui.calc.ngzf)); }else{ /*switch to automatic values*/ - gtk_widget_set_sensitive(vasp_gui.ngx,FALSE); - gtk_widget_set_sensitive(vasp_gui.ngy,FALSE); - gtk_widget_set_sensitive(vasp_gui.ngz,FALSE); - gtk_widget_set_sensitive(vasp_gui.ngxf,FALSE); - gtk_widget_set_sensitive(vasp_gui.ngyf,FALSE); - gtk_widget_set_sensitive(vasp_gui.ngzf,FALSE); + GUI_LOCK(vasp_gui.ngx); + GUI_LOCK(vasp_gui.ngy); + GUI_LOCK(vasp_gui.ngz); + GUI_LOCK(vasp_gui.ngxf); + GUI_LOCK(vasp_gui.ngyf); + GUI_LOCK(vasp_gui.ngzf); } } /***************************/ @@ -947,12 +947,12 @@ void ismear_changed(GtkWidget *w, struct model_pak *model){ const gchar *label = gtk_entry_get_text(GTK_ENTRY(w)); sscanf(label,"%i",&(vasp_gui.calc.ismear)); if(vasp_gui.calc.ismear==-5) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.have_tetra),TRUE); - gtk_widget_set_sensitive(vasp_gui.have_tetra,TRUE); + GUI_TOGGLE_ON(vasp_gui.have_tetra); + GUI_UNLOCK(vasp_gui.have_tetra); } else { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.have_tetra),FALSE); - gtk_widget_set_sensitive(vasp_gui.have_tetra,FALSE); + GUI_TOGGLE_OFF(vasp_gui.have_tetra); + GUI_LOCK(vasp_gui.have_tetra); } } /*****************************/ @@ -1000,9 +1000,9 @@ void vasp_gga_selected(GtkWidget *w, struct model_pak *model){ /*********************/ void vasp_metagga_selected(GtkWidget *w, struct model_pak *model){ const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gtk_widget_set_sensitive(vasp_gui.cmbj,FALSE); - gtk_widget_set_sensitive(vasp_gui.cmbja,FALSE); - gtk_widget_set_sensitive(vasp_gui.cmbjb,FALSE); + GUI_LOCK(vasp_gui.cmbj); + GUI_LOCK(vasp_gui.cmbja); + GUI_LOCK(vasp_gui.cmbjb); switch(index){ case 0://TPSS vasp_gui.calc.mgga=VMG_TPSS;break; @@ -1013,9 +1013,9 @@ void vasp_metagga_selected(GtkWidget *w, struct model_pak *model){ case 3://MBJ default: vasp_gui.calc.mgga=VMG_MBJ; - gtk_widget_set_sensitive(vasp_gui.cmbj,TRUE); - gtk_widget_set_sensitive(vasp_gui.cmbja,TRUE); - gtk_widget_set_sensitive(vasp_gui.cmbjb,TRUE); + GUI_UNLOCK(vasp_gui.cmbj); + GUI_UNLOCK(vasp_gui.cmbja); + GUI_UNLOCK(vasp_gui.cmbjb); } } /*******************/ @@ -1024,17 +1024,17 @@ void vasp_metagga_selected(GtkWidget *w, struct model_pak *model){ void metagga_toggle(GtkWidget *w, GtkWidget *box){ if(!vasp_gui.calc.lmetagga){ /*switch to manual values*/ - gtk_widget_set_sensitive(vasp_gui.metagga,FALSE); - gtk_widget_set_sensitive(vasp_gui.cmbj,FALSE); - gtk_widget_set_sensitive(vasp_gui.cmbja,FALSE); - gtk_widget_set_sensitive(vasp_gui.cmbjb,FALSE); + GUI_LOCK(vasp_gui.metagga); + GUI_LOCK(vasp_gui.cmbj); + GUI_LOCK(vasp_gui.cmbja); + GUI_LOCK(vasp_gui.cmbjb); }else{ /*switch to automatic values*/ - gtk_widget_set_sensitive(vasp_gui.metagga,TRUE); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.metagga),3);//MBJ (actually there is no default) - gtk_widget_set_sensitive(vasp_gui.cmbj,TRUE); - gtk_widget_set_sensitive(vasp_gui.cmbja,TRUE); - gtk_widget_set_sensitive(vasp_gui.cmbjb,TRUE); + GUI_UNLOCK(vasp_gui.metagga); + GUI_COMBOBOX_SET(vasp_gui.metagga,3);//MBJ (actually there is no default) + GUI_UNLOCK(vasp_gui.cmbj); + GUI_UNLOCK(vasp_gui.cmbja); + GUI_UNLOCK(vasp_gui.cmbjb); } } /*******************/ @@ -1043,20 +1043,20 @@ void metagga_toggle(GtkWidget *w, GtkWidget *box){ void ldau_toggle(GtkWidget *w, GtkWidget *box){ if(!vasp_gui.calc.ldau){ /*switch to manual values*/ - gtk_widget_set_sensitive(vasp_gui.ldau,FALSE); - gtk_widget_set_sensitive(vasp_gui.ldau_print,FALSE); - gtk_widget_set_sensitive(vasp_gui.ldaul,FALSE); - gtk_widget_set_sensitive(vasp_gui.ldauu,FALSE); - gtk_widget_set_sensitive(vasp_gui.ldauj,FALSE); + GUI_LOCK(vasp_gui.ldau); + GUI_LOCK(vasp_gui.ldau_print); + GUI_LOCK(vasp_gui.ldaul); + GUI_LOCK(vasp_gui.ldauu); + GUI_LOCK(vasp_gui.ldauj); }else{ /*switch to automatic values*/ - gtk_widget_set_sensitive(vasp_gui.ldau,TRUE); - gtk_widget_set_sensitive(vasp_gui.ldau_print,TRUE); - gtk_widget_set_sensitive(vasp_gui.ldaul,TRUE); - gtk_widget_set_sensitive(vasp_gui.ldauu,TRUE); - gtk_widget_set_sensitive(vasp_gui.ldauj,TRUE); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ldau),1);//2:LSDA+U Dudarev - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ldau_print),0);//0:Silent + GUI_UNLOCK(vasp_gui.ldau); + GUI_UNLOCK(vasp_gui.ldau_print); + GUI_UNLOCK(vasp_gui.ldaul); + GUI_UNLOCK(vasp_gui.ldauu); + GUI_UNLOCK(vasp_gui.ldauj); + GUI_COMBOBOX_SET(vasp_gui.ldau,1);//2:LSDA+U Dudarev + GUI_COMBOBOX_SET(vasp_gui.ldau_print,0);//0:Silent /*TODO: update ldaul, ldauu, ldauj*/ } } @@ -1095,39 +1095,38 @@ void vasp_ldau_print_selected(GtkWidget *w, struct model_pak *model){ /************************************/ void mixer_toggle(GtkWidget *w, GtkWidget *box){ if((vasp_gui.calc.auto_mixer)){ - /*switch to manual values*/ - gtk_widget_set_sensitive(vasp_gui.mixer,FALSE); - gtk_widget_set_sensitive(vasp_gui.amix,FALSE); - gtk_widget_set_sensitive(vasp_gui.bmix,FALSE); - gtk_widget_set_sensitive(vasp_gui.amin,FALSE); - gtk_widget_set_sensitive(vasp_gui.amix_mag,FALSE); - gtk_widget_set_sensitive(vasp_gui.bmix_mag,FALSE); - gtk_widget_set_sensitive(vasp_gui.maxmix,FALSE); - gtk_widget_set_sensitive(vasp_gui.wc,FALSE); - gtk_widget_set_sensitive(vasp_gui.inimix,FALSE); - gtk_widget_set_sensitive(vasp_gui.mixpre,FALSE); + /*switch to manual values*/ + GUI_LOCK(vasp_gui.mixer); + GUI_LOCK(vasp_gui.amix); + GUI_LOCK(vasp_gui.bmix); + GUI_LOCK(vasp_gui.amin); + GUI_LOCK(vasp_gui.amix_mag); + GUI_LOCK(vasp_gui.bmix_mag); + GUI_LOCK(vasp_gui.maxmix); + GUI_LOCK(vasp_gui.wc); + GUI_LOCK(vasp_gui.inimix); + GUI_LOCK(vasp_gui.mixpre); }else{ /*switch to automatic values*/ - gtk_widget_set_sensitive(vasp_gui.mixer,TRUE); - gtk_widget_set_sensitive(vasp_gui.amix,TRUE); - gtk_widget_set_sensitive(vasp_gui.bmix,TRUE); - gtk_widget_set_sensitive(vasp_gui.amin,TRUE); - gtk_widget_set_sensitive(vasp_gui.amix_mag,TRUE); - gtk_widget_set_sensitive(vasp_gui.bmix_mag,TRUE); - gtk_widget_set_sensitive(vasp_gui.maxmix,TRUE); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.mixer),3);//4:BROYDEN - gtk_entry_set_text(GTK_ENTRY(vasp_gui.amix),g_strdup_printf("%.4lf",vasp_gui.calc.amix)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.bmix),g_strdup_printf("%.4lf",vasp_gui.calc.bmix)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.amin),g_strdup_printf("%.4lf",vasp_gui.calc.amin)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.amix_mag),g_strdup_printf("%.4lf",vasp_gui.calc.amix_mag)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.bmix_mag),g_strdup_printf("%.4lf",vasp_gui.calc.bmix_mag)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.maxmix),g_strdup_printf("%i",vasp_gui.calc.maxmix)); + GUI_UNLOCK(vasp_gui.mixer); + GUI_UNLOCK(vasp_gui.amix); + GUI_UNLOCK(vasp_gui.bmix); + GUI_UNLOCK(vasp_gui.amin); + GUI_UNLOCK(vasp_gui.amix_mag); + GUI_UNLOCK(vasp_gui.bmix_mag); + GUI_UNLOCK(vasp_gui.maxmix); + GUI_COMBOBOX_SET(vasp_gui.mixer,3);//4:BROYDEN + GUI_ENTRY_TEXT(vasp_gui.amix,g_strdup_printf("%.4lf",vasp_gui.calc.amix)); + GUI_ENTRY_TEXT(vasp_gui.bmix,g_strdup_printf("%.4lf",vasp_gui.calc.bmix)); + GUI_ENTRY_TEXT(vasp_gui.amin,g_strdup_printf("%.4lf",vasp_gui.calc.amin)); + GUI_ENTRY_TEXT(vasp_gui.amix_mag,g_strdup_printf("%.4lf",vasp_gui.calc.amix_mag)); + GUI_ENTRY_TEXT(vasp_gui.bmix_mag,g_strdup_printf("%.4lf",vasp_gui.calc.bmix_mag)); + GUI_ENTRY_TEXT(vasp_gui.maxmix,g_strdup_printf("%i",vasp_gui.calc.maxmix)); if(vasp_gui.calc.imix==VM_4){ - gtk_widget_set_sensitive(vasp_gui.wc,TRUE); - gtk_widget_set_sensitive(vasp_gui.inimix,TRUE); - gtk_widget_set_sensitive(vasp_gui.mixpre,TRUE); + GUI_UNLOCK(vasp_gui.wc); + GUI_UNLOCK(vasp_gui.inimix); + GUI_UNLOCK(vasp_gui.mixpre); } - } } /*******************/ @@ -1135,9 +1134,9 @@ void mixer_toggle(GtkWidget *w, GtkWidget *box){ /*******************/ void vasp_mixer_selected(GtkWidget *w, struct model_pak *model){ const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gtk_widget_set_sensitive(vasp_gui.wc,FALSE); - gtk_widget_set_sensitive(vasp_gui.inimix,FALSE); - gtk_widget_set_sensitive(vasp_gui.mixpre,FALSE); + GUI_LOCK(vasp_gui.wc); + GUI_LOCK(vasp_gui.inimix); + GUI_LOCK(vasp_gui.mixpre); switch(index){ case 0://0:NO MIXING vasp_gui.calc.imix=VM_0;break; @@ -1148,9 +1147,9 @@ void vasp_mixer_selected(GtkWidget *w, struct model_pak *model){ case 3://4:BROYDEN default: vasp_gui.calc.imix=VM_4; - gtk_widget_set_sensitive(vasp_gui.wc,TRUE); - gtk_widget_set_sensitive(vasp_gui.inimix,TRUE); - gtk_widget_set_sensitive(vasp_gui.mixpre,TRUE); + GUI_UNLOCK(vasp_gui.wc); + GUI_UNLOCK(vasp_gui.inimix); + GUI_UNLOCK(vasp_gui.mixpre); } } /***************************/ @@ -1186,11 +1185,11 @@ void vasp_mixpre_selected(GtkWidget *w, struct model_pak *model){ /********************/ void vasp_idipol_selected(GtkWidget *w, struct model_pak *model){ const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gtk_widget_set_sensitive(vasp_gui.ldipol,TRUE); - gtk_widget_set_sensitive(vasp_gui.lmono,TRUE); - gtk_widget_set_sensitive(vasp_gui.dipol,TRUE); - gtk_widget_set_sensitive(vasp_gui.epsilon,TRUE); - gtk_widget_set_sensitive(vasp_gui.efield,TRUE); + GUI_UNLOCK(vasp_gui.ldipol); + GUI_UNLOCK(vasp_gui.lmono); + GUI_UNLOCK(vasp_gui.dipol); + GUI_UNLOCK(vasp_gui.epsilon); + GUI_UNLOCK(vasp_gui.efield); switch(index){ case 1://1:u axis vasp_gui.calc.idipol=VID_1;break; @@ -1200,16 +1199,16 @@ void vasp_idipol_selected(GtkWidget *w, struct model_pak *model){ vasp_gui.calc.idipol=VID_3;break; case 4://4:all axis vasp_gui.calc.idipol=VID_4; - gtk_widget_set_sensitive(vasp_gui.efield,FALSE);/*not implemented*/ + GUI_LOCK(vasp_gui.efield); break; case 0://0:no calcul default: vasp_gui.calc.idipol=VID_0; - gtk_widget_set_sensitive(vasp_gui.ldipol,FALSE); - gtk_widget_set_sensitive(vasp_gui.lmono,FALSE); - gtk_widget_set_sensitive(vasp_gui.dipol,FALSE); - gtk_widget_set_sensitive(vasp_gui.epsilon,FALSE); - gtk_widget_set_sensitive(vasp_gui.efield,FALSE); + GUI_LOCK(vasp_gui.ldipol); + GUI_LOCK(vasp_gui.lmono); + GUI_LOCK(vasp_gui.dipol); + GUI_LOCK(vasp_gui.epsilon); + GUI_LOCK(vasp_gui.efield); } } /********************/ @@ -1240,24 +1239,24 @@ void vasp_lorbit_selected(GtkWidget *w, struct model_pak *model){ /********************/ void vasp_ibrion_selected(GtkWidget *w, struct model_pak *model){ const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gtk_widget_set_sensitive(vasp_gui.tebeg,FALSE); - gtk_widget_set_sensitive(vasp_gui.teend,FALSE); - gtk_widget_set_sensitive(vasp_gui.smass,FALSE); - gtk_widget_set_sensitive(vasp_gui.nblock,FALSE); - gtk_widget_set_sensitive(vasp_gui.kblock,FALSE); - gtk_widget_set_sensitive(vasp_gui.npaco,FALSE); - gtk_widget_set_sensitive(vasp_gui.apaco,FALSE); +GUI_LOCK(vasp_gui.tebeg); +GUI_LOCK(vasp_gui.teend); +GUI_LOCK(vasp_gui.smass); +GUI_LOCK(vasp_gui.nblock); +GUI_LOCK(vasp_gui.kblock); +GUI_LOCK(vasp_gui.npaco); +GUI_LOCK(vasp_gui.apaco); switch(index){ case 1://0:Molecular Dynamics vasp_gui.calc.ibrion=0; /*molecular dynamics part*/ - gtk_widget_set_sensitive(vasp_gui.tebeg,TRUE); - gtk_widget_set_sensitive(vasp_gui.teend,TRUE); - gtk_widget_set_sensitive(vasp_gui.smass,TRUE); - gtk_widget_set_sensitive(vasp_gui.nblock,TRUE); - gtk_widget_set_sensitive(vasp_gui.kblock,TRUE); - gtk_widget_set_sensitive(vasp_gui.npaco,TRUE); - gtk_widget_set_sensitive(vasp_gui.apaco,TRUE); +GUI_UNLOCK(vasp_gui.tebeg); +GUI_UNLOCK(vasp_gui.teend); +GUI_UNLOCK(vasp_gui.smass); +GUI_UNLOCK(vasp_gui.nblock); +GUI_UNLOCK(vasp_gui.kblock); +GUI_UNLOCK(vasp_gui.npaco); +GUI_UNLOCK(vasp_gui.apaco); break; case 2://1:Quasi-Newton vasp_gui.calc.ibrion=1;break; @@ -2721,7 +2720,7 @@ void gui_vasp_dialog(void){ g_free(title); vasp_gui.window = dialog_window(dialog); /* --- Outside of notebook */ - GUI_FRAME_BOX(GTK_DIALOG(vasp_gui.window)->vbox,frame); + GUI_FRAME_WINDOW(vasp_gui.window,frame); GUI_VBOX_FRAME(frame,vbox); /* --- MODEL NAME */ GUI_LINE_BOX(vbox,hbox); @@ -2736,7 +2735,7 @@ GUI_TOOLTIP(vasp_gui.name,"The model name will be used in VASP files\nas well as GUI_TOOLTIP(vasp_gui.file_entry,"Use the result of a calculation (vasprun.xml)\nas a model to fill up settings of the current one.\nNOTE: important settings (such as NELM) will be wrong\nand all settings should be checked again. Carefully."); GUI_OPEN_BUTTON_BOX(hbox,button,load_vasprun_dialog); /* create frame in box */ - GUI_FRAME_BOX(GTK_DIALOG(vasp_gui.window)->vbox,frame); + GUI_FRAME_WINDOW(vasp_gui.window,frame); /* create notebook in frame */ GUI_NOTE_FRAME(frame,notebook); @@ -2784,7 +2783,7 @@ GUI_TOOLTIP(vasp_gui.simple_species,"From POTCAR file, the following species are /* 4th line */ GUI_TEXT_TABLE(table,vasp_gui.simple_potcar,vasp_gui.calc.potcar_file,"POTCAR FILE:",0,3,3,4); GUI_TOOLTIP(vasp_gui.simple_potcar,"Where is the POTCAR file for this calculation?"); - GUI_BUTTON_TABLE(table,vasp_gui.simple_potcar_button,GTK_STOCK_OPEN,load_potcar_file_dialog,3,4,3,4); + GUI_OPEN_BUTTON_TABLE(table,vasp_gui.simple_potcar_button,load_potcar_file_dialog,3,4,3,4); /* 5th line */ GUI_LEFT_LABEL_TABLE(table,"EXEC:",0,1,4,5); GUI_SPIN_TABLE(table,vasp_gui.simple_np,vasp_gui.calc.job_nproc,parallel_eq,"NP=",1,2,4,5); @@ -2808,7 +2807,7 @@ GUI_TOOLTIP(vasp_gui.simple_kpar,"How many k-points should be worked on at a tim GUI_LABEL_TABLE(table,"for a given calculation type. User should then check said defaults extremely carefuly...",1,2,1,2); /* 3th line */ GUI_LABEL_TABLE(table,"GENERATE ==>",0,1,3,4); - GUI_BUTTON_TABLE(table,vasp_gui.simple_apply,GTK_STOCK_APPLY,vasp_apply_simple,1,2,3,4); + GUI_APPLY_BUTTON_TABLE(table,vasp_gui.simple_apply,vasp_apply_simple,1,2,3,4); GUI_TOOLTIP(vasp_gui.simple_apply,"Use this to obtain a preset of setting.\nIf calculation is already set using this will\noverwrite settings resulting in an unpredictable state."); GUI_LABEL_TABLE(table,"<== (and check...)",2,3,3,4); /* --- end frame */ @@ -3438,11 +3437,11 @@ if((vasp_gui.calc.poscar_free==VPF_FIXED)||(vasp_gui.calc.poscar_free==VPF_FREE) /* create a table in the frame*/ GUI_TABLE_FRAME(frame,table,1,5); /* 1st line */ - VASP_ENTRY_TABLE(vasp_gui.ismear_3,vasp_gui.calc.ismear,"%i","ISMEAR=",0,1,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.ismear_3,vasp_gui.calc.ismear,"%i","ISMEAR=",0,1,0,1); GUI_TOOLTIP(vasp_gui.ismear_3,"ISMEAR: Ch. 6.38 DEFAULT: 1\nDetermine how the partial occupations are set.\nIt is advised to change it to ISMEAR=0\nfor semiconducting or insulating materials."); - VASP_CHECK_TABLE(vasp_gui.kgamma_3,vasp_gui.calc.kgamma,NULL,"KGAMMA",1,2,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.kgamma_3,vasp_gui.calc.kgamma,NULL,"KGAMMA",1,2,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.kgamma_3,"KGAMMA: Ch. 6.4 DEFAULT: TRUE\nWhen KPOINTS file is not present KGAMMA\nindicate if the k-grid is centered around gamma point."); - VASP_ENTRY_TABLE(vasp_gui.kspacing_3,vasp_gui.calc.kspacing,"%.4f","KSPACING=",2,3,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.kspacing_3,vasp_gui.calc.kspacing,"%.4f","KSPACING=",2,3,0,1); GUI_TOOLTIP(vasp_gui.kspacing_3,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS file is not present KSPACING\nDetermine the smallest spacing between k-points (Ang^-1)."); /*empty: col3*/ /*empty: col4*/ @@ -3452,32 +3451,32 @@ GUI_TOOLTIP(vasp_gui.kspacing_3,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS fi /* create a table in the frame*/ GUI_TABLE_FRAME(frame,table,2,5); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.kpoints_mode,"GEN:",0,1,0,1); - VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Manual Entry"); - VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Line Mode"); - VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Automatic (M&P)"); - VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Gamma (M&P)"); - VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Monkhorst-Pack classic"); - VASP_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Basis set definition"); + GUI_COMBOBOX_TABLE(table,vasp_gui.kpoints_mode,"GEN:",0,1,0,1); + GUI_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Manual Entry"); + GUI_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Line Mode"); + GUI_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Automatic (M&P)"); + GUI_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Gamma (M&P)"); + GUI_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Monkhorst-Pack classic"); + GUI_COMBOBOX_ADD(vasp_gui.kpoints_mode,"Basis set definition"); GUI_TOOLTIP(vasp_gui.kpoints_mode,"Sets how the k-points are generated/entered as defined in Ch. 5.5."); - VASP_CHECK_TABLE(vasp_gui.kpoints_cart,vasp_gui.calc.kpoints_cart,NULL,"Cartesian",1,2,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,vasp_gui.kpoints_cart,vasp_gui.calc.kpoints_cart,NULL,"Cartesian",1,2,0,1);/*not calling anything*/ GUI_TOOLTIP(vasp_gui.kpoints_cart,"Switch cartesian/reciprocal lattice coordinate mode."); - VASP_SPIN_TABLE(vasp_gui.kpoints_kx,vasp_gui.calc.kpoints_kx,NULL,"KX",2,3,0,1); + GUI_SPIN_TABLE(table,vasp_gui.kpoints_kx,vasp_gui.calc.kpoints_kx,NULL,"KX",2,3,0,1); GUI_TOOLTIP(vasp_gui.kpoints_kx,"Grid size for automated generation\n1st component only for M&P."); - VASP_SPIN_TABLE(vasp_gui.kpoints_ky,vasp_gui.calc.kpoints_ky,NULL,"KY",3,4,0,1); + GUI_SPIN_TABLE(table,vasp_gui.kpoints_ky,vasp_gui.calc.kpoints_ky,NULL,"KY",3,4,0,1); GUI_TOOLTIP(vasp_gui.kpoints_ky,"2nd Component of the M&P grid size."); - VASP_SPIN_TABLE(vasp_gui.kpoints_kz,vasp_gui.calc.kpoints_kz,NULL,"KZ",4,5,0,1); + GUI_SPIN_TABLE(table,vasp_gui.kpoints_kz,vasp_gui.calc.kpoints_kz,NULL,"KZ",4,5,0,1); GUI_TOOLTIP(vasp_gui.kpoints_kz,"3rd Component of the M&P grid size."); /* 2nd line */ - VASP_ENTRY_TABLE(vasp_gui.kpoints_nkpts,vasp_gui.calc.kpoints_nkpts,"%i","NKPTS=",0,1,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_nkpts,vasp_gui.calc.kpoints_nkpts,"%i","NKPTS=",0,1,1,2); GUI_TOOLTIP(vasp_gui.kpoints_nkpts,"Total number of k-points (0 for automated methods)."); - VASP_CHECK_TABLE(vasp_gui.have_tetra,vasp_gui.calc.kpoints_tetra,toogle_tetra,"Tetrahedron",1,2,1,2); + GUI_CHECK_TABLE(table,vasp_gui.have_tetra,vasp_gui.calc.kpoints_tetra,toogle_tetra,"Tetrahedron",1,2,1,2); GUI_TOOLTIP(vasp_gui.have_tetra,"Switch on the tetrahedron method for entering k-points.\nISMEAR must be set to -5 for this method!"); - VASP_ENTRY_TABLE(vasp_gui.kpoints_sx,vasp_gui.calc.kpoints_sx,"%.4lf","SX=",2,3,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_sx,vasp_gui.calc.kpoints_sx,"%.4lf","SX=",2,3,1,2); GUI_TOOLTIP(vasp_gui.kpoints_sx,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 1st reciprocal lattice component."); - VASP_ENTRY_TABLE(vasp_gui.kpoints_sy,vasp_gui.calc.kpoints_sy,"%.4lf","SY=",3,4,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_sy,vasp_gui.calc.kpoints_sy,"%.4lf","SY=",3,4,1,2); GUI_TOOLTIP(vasp_gui.kpoints_sy,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 2nd reciprocal lattice component."); - VASP_ENTRY_TABLE(vasp_gui.kpoints_sz,vasp_gui.calc.kpoints_sz,"%.4lf","SZ=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_sz,vasp_gui.calc.kpoints_sz,"%.4lf","SZ=",4,5,1,2); GUI_TOOLTIP(vasp_gui.kpoints_sz,"In case a grid is used to generate k-points\nThis will set a shift from grid origin\nin 3rd reciprocal lattice component."); /* --- end frame */ /* --- Coordinate */ @@ -3485,26 +3484,22 @@ GUI_TOOLTIP(vasp_gui.kpoints_sz,"In case a grid is used to generate k-points\nTh /* create a table in the frame*/ GUI_TABLE_FRAME(vasp_gui.kpoints_coord,table,2,5); /* 1st line */ - VASP_COMBOBOX_TABLE(vasp_gui.kpoints_kpts,"KPOINT:",0,4,0,1); - VASP_COMBOBOX_ADD(vasp_gui.kpoints_kpts,"ADD kpoint"); + GUI_COMBOBOX_TABLE(table,vasp_gui.kpoints_kpts,"KPOINT:",0,4,0,1); + GUI_COMBOBOX_ADD(vasp_gui.kpoints_kpts,"ADD kpoint"); GUI_TOOLTIP(vasp_gui.kpoints_kpts,"List of the k-points coordinates.\nThe index after comment sign \"! kpoint:\" can be used\nfor entering tetrahedron edge definition."); /*2 buttons*/ - hbox = gtk_hbox_new(FALSE, 0); - VASP_NEW_SEPARATOR(); - gui_stock_button(GTK_STOCK_APPLY,vasp_kpoint_modified,NULL,hbox); - gui_stock_button(GTK_STOCK_DELETE,vasp_kpoint_delete,NULL,hbox); - gtk_table_attach_defaults(GTK_TABLE(table),hbox,4,5,0,1); + GUI_2BUTTONS_TABLE(table,vasp_kpoint_modified,vasp_kpoint_delete,4,5,0,1); /* 2nd line */ - VASP_ENTRY_TABLE(vasp_gui.kpoints_i,vasp_gui.calc.kpoints_i,"%i","INDEX:",0,1,1,2); - gtk_widget_set_sensitive(vasp_gui.kpoints_i,FALSE);/*<- is changed only by selecting kpoints_kpts*/ + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_i,vasp_gui.calc.kpoints_i,"%i","INDEX:",0,1,1,2); + GUI_LOCK(vasp_gui.kpoints_i);/*<- is changed only by selecting kpoints_kpts*/ GUI_TOOLTIP(vasp_gui.kpoints_i,"The index of current k-point.\n(can be changed by deletion/addition only)"); - VASP_ENTRY_TABLE(vasp_gui.kpoints_x,vasp_gui.calc.kpoints_x,"%.4lf","X=",1,2,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_x,vasp_gui.calc.kpoints_x,"%.4lf","X=",1,2,1,2); GUI_TOOLTIP(vasp_gui.kpoints_x,"Coordinate of k-point in 1st component of selected mode.\n(cartesian or reciprocal)"); - VASP_ENTRY_TABLE(vasp_gui.kpoints_y,vasp_gui.calc.kpoints_y,"%.4lf","Y=",2,3,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_y,vasp_gui.calc.kpoints_y,"%.4lf","Y=",2,3,1,2); GUI_TOOLTIP(vasp_gui.kpoints_y,"Coordinate of k-point in 2nd component of selected mode.\n(cartesian or reciprocal)"); - VASP_ENTRY_TABLE(vasp_gui.kpoints_z,vasp_gui.calc.kpoints_z,"%.4lf","Z=",3,4,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_z,vasp_gui.calc.kpoints_z,"%.4lf","Z=",3,4,1,2); GUI_TOOLTIP(vasp_gui.kpoints_z,"Coordinate of k-point in 3rd component of selected mode.\n(cartesian or reciprocal)"); - VASP_ENTRY_TABLE(vasp_gui.kpoints_w,vasp_gui.calc.kpoints_w,"%.4lf","W=",4,5,1,2); + GUI_ENTRY_TABLE(table,vasp_gui.kpoints_w,vasp_gui.calc.kpoints_w,"%.4lf","W=",4,5,1,2); GUI_TOOLTIP(vasp_gui.kpoints_w,"Symmetry degeneration weight of k-point.\nSum of all weight does not have to be 1\nbut relative ratio should be respected."); /* --- end frame */ /* --- Tetrahedron */ @@ -3512,45 +3507,40 @@ GUI_TOOLTIP(vasp_gui.kpoints_w,"Symmetry degeneration weight of k-point.\nSum of /* create a table in the frame*/ GUI_TABLE_FRAME(vasp_gui.kpoints_tetra,table,3,6); /* 1st line */ - VASP_ENTRY_TABLE(vasp_gui.tetra_total,vasp_gui.calc.tetra_total,"%i","TOTAL=",0,1,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.tetra_total,vasp_gui.calc.tetra_total,"%i","TOTAL=",0,1,0,1); GUI_TOOLTIP(vasp_gui.tetra_total,"Total number of tetrahedrons."); - label = gtk_label_new("EXACT VOLUME:"); - gtk_table_attach_defaults(GTK_TABLE(table),label,1,2,0,1); - VASP_ENTRY_TABLE(vasp_gui.tetra_volume,vasp_gui.calc.tetra_volume,"%.6lf","V=",2,3,0,1); + GUI_LABEL_TABLE(table,"EXACT VOLUME:",1,2,0,1); + GUI_ENTRY_TABLE(table,vasp_gui.tetra_volume,vasp_gui.calc.tetra_volume,"%.6lf","V=",2,3,0,1); GUI_TOOLTIP(vasp_gui.tetra_volume,"Volume weight for a single tetrahedron.\nAll have a volume defined by the ratio of\ntetrahedron volume / Brillouin zone Volume."); - label = gtk_label_new("for (A,B,C,D) tetrahedron"); - gtk_table_attach_defaults(GTK_TABLE(table),label,3,6,0,1); + GUI_LABEL_TABLE(table,"for (A,B,C,D) tetrahedron",3,6,0,1); /* 2nd line */ - VASP_COMBOBOX_TABLE(vasp_gui.tetra,"TETRAHEDRON:",0,5,1,2); - VASP_COMBOBOX_ADD(vasp_gui.tetra,"ADD tetrahedron"); + GUI_COMBOBOX_TABLE(table,vasp_gui.tetra,"TETRAHEDRON:",0,5,1,2); + GUI_COMBOBOX_ADD(vasp_gui.tetra,"ADD tetrahedron"); GUI_TOOLTIP(vasp_gui.tetra,"Tetrahedron list, consisting of\nsymmetry degeneration weight followed by\nfour corner points of each tetrahedron\nin k-point indices given above."); /*2 buttons*/ - hbox = gtk_hbox_new(FALSE, 0); - VASP_NEW_SEPARATOR(); - gui_stock_button(GTK_STOCK_APPLY,vasp_tetra_modified,NULL,hbox); - gui_stock_button(GTK_STOCK_DELETE,vasp_tetra_delete,NULL,hbox); - gtk_table_attach_defaults(GTK_TABLE(table),hbox,5,6,1,2); + GUI_2BUTTONS_TABLE(table,vasp_tetra_modified,vasp_tetra_delete,5,6,1,2); /* 3rd line */ - VASP_ENTRY_TABLE(vasp_gui.tetra_i,vasp_gui.calc.tetra_i,"%i","INDEX:",0,1,2,3); - gtk_widget_set_sensitive(vasp_gui.tetra_i,FALSE);/*<- is changed only by selecting tetra*/ + GUI_ENTRY_TABLE(table,vasp_gui.tetra_i,vasp_gui.calc.tetra_i,"%i","INDEX:",0,1,2,3); + GUI_LOCK(vasp_gui.tetra_i);/*<- is changed only by selecting tetra*/ GUI_TOOLTIP(vasp_gui.tetra_i,"The index of current tetrahedron.\n(can be changed by deletion/addition only)"); - VASP_ENTRY_TABLE(vasp_gui.tetra_w,vasp_gui.calc.tetra_w,"%.4lf","Degen. W=",1,2,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.tetra_w,vasp_gui.calc.tetra_w,"%.4lf","Degen. W=",1,2,2,3); GUI_TOOLTIP(vasp_gui.tetra_w,"Symmetry degeneration weight.\nUnlike k-points, weight must be normalized\nie. total Brillouin zone Volume should be recovered\nby summing all degeneration * V"); - VASP_ENTRY_TABLE(vasp_gui.tetra_a,vasp_gui.calc.tetra_a,"%i","PtA:",2,3,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.tetra_a,vasp_gui.calc.tetra_a,"%i","PtA:",2,3,2,3); GUI_TOOLTIP(vasp_gui.tetra_a,"1st corner of the tetrahedron (A) in k-point index."); - VASP_ENTRY_TABLE(vasp_gui.tetra_b,vasp_gui.calc.tetra_b,"%i","PtB:",3,4,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.tetra_b,vasp_gui.calc.tetra_b,"%i","PtB:",3,4,2,3); GUI_TOOLTIP(vasp_gui.tetra_b,"2nd corner of the tetrahedron (B) in k-point index."); - VASP_ENTRY_TABLE(vasp_gui.tetra_c,vasp_gui.calc.tetra_c,"%i","PtC:",4,5,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.tetra_c,vasp_gui.calc.tetra_c,"%i","PtC:",4,5,2,3); GUI_TOOLTIP(vasp_gui.tetra_c,"3rd corner of the tetrahedron (C) in k-point index."); - VASP_ENTRY_TABLE(vasp_gui.tetra_d,vasp_gui.calc.tetra_d,"%i","PtD:",5,6,2,3); + GUI_ENTRY_TABLE(table,vasp_gui.tetra_d,vasp_gui.calc.tetra_d,"%i","PtD:",5,6,2,3); GUI_TOOLTIP(vasp_gui.tetra_d,"4th corner of the tetrahedron (D) in k-point index."); /* initialize */ - g_signal_connect(GTK_OBJECT(GTK_ENTRY(vasp_gui.ismear_3)),"changed",GTK_SIGNAL_FUNC(ismear_changed),data); - g_signal_connect(GTK_OBJECT(GTK_ENTRY(vasp_gui.kspacing_3)),"changed",GTK_SIGNAL_FUNC(kspacing_changed),data); - VASP_COMBOBOX_SETUP(vasp_gui.kpoints_mode,vasp_gui.calc.kpoints_mode,vasp_kpoints_mode_selected); - VASP_COMBOBOX_SETUP(vasp_gui.kpoints_kpts,0,vasp_kpoints_kpts_selected); - VASP_COMBOBOX_SETUP(vasp_gui.tetra,0,vasp_tetra_selected); + GUI_ENTRY_CHANGE(vasp_gui.ismear_3,ismear_changed,data); + GUI_ENTRY_CHANGE(vasp_gui.kspacing_3,kspacing_changed,data); + GUI_COMBOBOX_SETUP(vasp_gui.kpoints_mode,vasp_gui.calc.kpoints_mode,vasp_kpoints_mode_selected); + GUI_COMBOBOX_SETUP(vasp_gui.kpoints_kpts,0,vasp_kpoints_kpts_selected); + GUI_COMBOBOX_SETUP(vasp_gui.tetra,0,vasp_tetra_selected); toogle_tetra(); + ismear_changed(vasp_gui.ismear_3,data);/*necessary*/ /* --- end frame */ /* TODO: import KPOINTS/IBZKPT file*/ @@ -3563,12 +3553,11 @@ GUI_TOOLTIP(vasp_gui.tetra_d,"4th corner of the tetrahedron (D) in k-point index /* create a table in the frame*/ GUI_TABLE_FRAME(frame,table,2,1); /* 1st line */ - VASP_TEXT_TABLE(vasp_gui.poscar_species,vasp_gui.calc.species_symbols,"SPECIES:",0,1,0,1); - gtk_widget_set_sensitive(vasp_gui.poscar_species,FALSE); + GUI_TEXT_TABLE(table,vasp_gui.poscar_species,vasp_gui.calc.species_symbols,"SPECIES:",0,1,0,1); + GUI_LOCK(vasp_gui.poscar_species); GUI_TOOLTIP(vasp_gui.poscar_species,"List of atomic symbol of the species\ndetected in the POSCAR ionic information."); /* 2nd line */ - label = gtk_label_new("(each species will require a separate POTCAR information)"); - gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,1,2); + GUI_LABEL_TABLE(table,"(each species will require a separate POTCAR information)",0,1,1,2); /* --- end frame */ /* --- get POTCAR information */ GUI_FRAME_NOTE(page,frame,"get POTCAR information"); @@ -3576,23 +3565,21 @@ GUI_TOOLTIP(vasp_gui.poscar_species,"List of atomic symbol of the species\ndetec GUI_TABLE_FRAME(frame,table,3,4); /* 1st line */ /* 2 lines radiobutton */ - vbox = gtk_vbox_new(FALSE,0); - new_radio_group(0,vbox,FF); - vasp_gui.potcar_select_file = add_radio_button("Use POTCAR file",(gpointer)toggle_potcar_file,NULL); - vasp_gui.potcar_select_folder = add_radio_button("Use POTCAR path",(gpointer)toggle_potcar_folder,NULL); - gtk_table_attach_defaults(GTK_TABLE(table),vbox,0,1,0,2); + GUI_2RADIO_TABLE(table, + vasp_gui.potcar_select_file,"Use POTCAR file",toggle_potcar_file, + vasp_gui.potcar_select_folder,"Use POTCAR path",toggle_potcar_folder,0,1,0,2); GUI_TOOLTIP(vasp_gui.potcar_select_file,"Load a previously prepared POTCAR file.\nThe species (and species order) should match\nEXACTLY those of the POSCAR ion information."); GUI_TOOLTIP(vasp_gui.potcar_select_folder,"Use the directory where all POTCAR information are available.\nUsually a directory containing atomic symbols sub-directories."); - VASP_TEXT_TABLE(vasp_gui.potcar_file,vasp_gui.calc.potcar_file,"FILE:",1,3,0,1); - VASP_BUTTON_TABLE(vasp_gui.potcar_file_button,GTK_STOCK_OPEN,load_potcar_file_dialog,3,4,0,1); + GUI_TEXT_TABLE(table,vasp_gui.potcar_file,vasp_gui.calc.potcar_file,"FILE:",1,3,0,1); + GUI_OPEN_BUTTON_TABLE(table,vasp_gui.potcar_file_button,load_potcar_file_dialog,3,4,0,1); GUI_TOOLTIP(vasp_gui.potcar_file,"POTCAR file, including its full path."); /* 2nd line */ - VASP_TEXT_TABLE(vasp_gui.potcar_folder,vasp_gui.calc.potcar_folder,"PATH:",1,3,1,2); - VASP_BUTTON_TABLE(vasp_gui.potcar_folder_button,GTK_STOCK_OPEN,load_potcar_folder_dialog,3,4,1,2); + GUI_TEXT_TABLE(table,vasp_gui.potcar_folder,vasp_gui.calc.potcar_folder,"PATH:",1,3,1,2); + GUI_OPEN_BUTTON_TABLE(table,vasp_gui.potcar_folder_button,load_potcar_folder_dialog,3,4,1,2); GUI_TOOLTIP(vasp_gui.potcar_folder,"Full PATH to the POTCAR sub-directories."); /* 3rd line */ - VASP_COMBOBOX_TABLE(vasp_gui.species_flavor,"FLAVOR:",2,3,2,3); - VASP_BUTTON_TABLE(vasp_gui.species_button,GTK_STOCK_APPLY,apply_species_flavor,3,4,2,3); + GUI_COMBOBOX_TABLE(table,vasp_gui.species_flavor,"FLAVOR:",2,3,2,3); + GUI_OPEN_BUTTON_TABLE(table,vasp_gui.species_button,apply_species_flavor,3,4,2,3); GUI_TOOLTIP(vasp_gui.species_flavor,"When Using PATH method, for each species a choice\nbetween different pseudopotential setting (flavors) exists\nEx: _h hard, _s soft _pv include pseudo-core valence, etc."); /* initialize */ toggle_potcar_file(NULL,NULL); @@ -3603,16 +3590,16 @@ GUI_TOOLTIP(vasp_gui.species_flavor,"When Using PATH method, for each species a GUI_TABLE_FRAME(frame,table,2,2); /* 1st line */ //multicolumn label - label = gtk_label_new("DETECTED"); - gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,0,2); - VASP_TEXT_TABLE(vasp_gui.potcar_species,vasp_gui.calc.potcar_species,"SPECIES:",1,2,0,1); + GUI_LABEL_TABLE(table,"DETECTED",0,1,0,2); + GUI_TEXT_TABLE(table,vasp_gui.potcar_species,vasp_gui.calc.potcar_species,"SPECIES:",1,2,0,1); GUI_TOOLTIP(vasp_gui.potcar_species,"List of atomic symbol of the species\ndetected from the POTCAR setting."); - gtk_widget_set_sensitive(vasp_gui.potcar_species,FALSE); + GUI_LOCK(vasp_gui.potcar_species); /* 2nd line */ /*occ: col0*/ - VASP_TEXT_TABLE(vasp_gui.potcar_species_flavor,vasp_gui.calc.potcar_species_flavor,"FLAVOR:",1,2,1,2); + GUI_TEXT_TABLE(table,vasp_gui.potcar_species_flavor,vasp_gui.calc.potcar_species_flavor,"FLAVOR:",1,2,1,2); GUI_TOOLTIP(vasp_gui.potcar_species_flavor,"List of the pseudopotential flavors (PATH method)\ndetected from the POTCAR setting."); - gtk_widget_set_sensitive(vasp_gui.potcar_species_flavor,FALSE); + GUI_LOCK(vasp_gui.potcar_species_flavor); +/* --- end frame */ /*----------------*/ /* page 6 -> EXEC */ @@ -3623,26 +3610,26 @@ GUI_TOOLTIP(vasp_gui.potcar_species_flavor,"List of the pseudopotential flavors /* create a table in the frame*/ GUI_TABLE_FRAME(frame,table,3,6); /* 1st line */ - VASP_LABEL_TABLE("VASP EXEC:",0,1,0,1); - VASP_TEXT_TABLE(vasp_gui.job_vasp_exe,vasp_gui.calc.job_vasp_exe,"FILE=",1,5,0,1); + GUI_LABEL_TABLE(table,"VASP EXEC:",0,1,0,1); + GUI_TEXT_TABLE(table,vasp_gui.job_vasp_exe,vasp_gui.calc.job_vasp_exe,"FILE=",1,5,0,1); GUI_TOOLTIP(vasp_gui.job_vasp_exe,"Location (full path) of the vasp executable."); - VASP_BUTTON_TABLE(button,GTK_STOCK_OPEN,load_vasp_exe_dialog,5,6,0,1); + GUI_OPEN_BUTTON_TABLE(table,button,load_vasp_exe_dialog,5,6,0,1); /* 2nd line */ - VASP_LABEL_TABLE("CALCUL PATH:",0,1,1,2); - VASP_TEXT_TABLE(vasp_gui.job_path,vasp_gui.calc.job_path,"PATH=",1,5,1,2); + GUI_LABEL_TABLE(table,"CALCUL PATH:",0,1,1,2); + GUI_TEXT_TABLE(table,vasp_gui.job_path,vasp_gui.calc.job_path,"PATH=",1,5,1,2); GUI_TOOLTIP(vasp_gui.job_path,"Location (full path) of the calculation directory.\nit is IMPORTANT to check this parameter so that\n* no other calculation is overwritten\n* calculation will not start in an unexpected directory."); - VASP_BUTTON_TABLE(button,GTK_STOCK_OPEN,load_path_dialog,5,6,1,2); + GUI_OPEN_BUTTON_TABLE(table,button,load_path_dialog,5,6,1,2); /* 3rd line */ - VASP_LABEL_TABLE("OUTPUT:",0,1,2,3); - VASP_CHECK_TABLE(button,vasp_gui.calc.lwave,NULL,"LWAVE",1,2,2,3);/*not calling anything*/ + GUI_LABEL_TABLE(table,"OUTPUT:",0,1,2,3); + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lwave,NULL,"LWAVE",1,2,2,3);/*not calling anything*/ GUI_TOOLTIP(button,"LWAVE: Ch. 6.52 DEFAULT: TRUE\nIf set the WAVECAR (wavefunctions) file is written."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lcharg,NULL,"LCHARG",2,3,2,3);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lcharg,NULL,"LCHARG",2,3,2,3);/*not calling anything*/ GUI_TOOLTIP(button,"LCHARG: Ch. 6.52 DEFAULT: TRUE\nIf set the CHGCAR (charge density) file is written."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lvtot,NULL,"LVTOT",3,4,2,3);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lvtot,NULL,"LVTOT",3,4,2,3);/*not calling anything*/ GUI_TOOLTIP(button,"LVTOT: Ch. 6.53 DEFAULT: FALSE\nIf set the LOCPOT (local potential) file is written."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lvhar,NULL,"LVHAR",4,5,2,3);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lvhar,NULL,"LVHAR",4,5,2,3);/*not calling anything*/ GUI_TOOLTIP(button,"LVHAR: Ch. 6.54 DEFAULT: FALSE\nIf set the full local potential is written to LOCPOT\n(ie. ionic+Hartree+XC) otherwise only electrostatic\n(ie. ionic+Hartree) is written."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lelf,NULL,"LELF",5,6,2,3);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lelf,NULL,"LELF",5,6,2,3);/*not calling anything*/ GUI_TOOLTIP(button,"LELF: Ch 6.55 DEFAULT: FALSE\nIf set the ELFCAR (electron localization function)\nfile is written."); /* --- end frame */ /* --- PARALLEL */ @@ -3650,22 +3637,22 @@ GUI_TOOLTIP(button,"LELF: Ch 6.55 DEFAULT: FALSE\nIf set the ELFCAR (electron lo /* create a table in the frame*/ GUI_TABLE_FRAME(frame,table,2,6); /* 1st line */ - VASP_LABEL_TABLE("MPIRUN:",0,1,0,1); - VASP_TEXT_TABLE(vasp_gui.job_mpirun,vasp_gui.calc.job_mpirun,"FILE=",1,5,0,1); + GUI_LABEL_TABLE(table,"MPIRUN:",0,1,0,1); + GUI_TEXT_TABLE(table,vasp_gui.job_mpirun,vasp_gui.calc.job_mpirun,"FILE=",1,5,0,1); GUI_TOOLTIP(vasp_gui.job_mpirun,"Location (full path) of mpirun executable.\nRequired for parallel calculation only."); - VASP_BUTTON_TABLE(button,GTK_STOCK_OPEN,load_mpirun_dialog,5,6,0,1); + GUI_OPEN_BUTTON_TABLE(table,button,load_mpirun_dialog,5,6,0,1); /* 2nd line */ - VASP_SPIN_TABLE(vasp_gui.job_nproc,vasp_gui.calc.job_nproc,parallel_eq,"NP=",0,1,1,2); + GUI_SPIN_TABLE(table,vasp_gui.job_nproc,vasp_gui.calc.job_nproc,parallel_eq,"NP=",0,1,1,2); GUI_TOOLTIP(vasp_gui.job_nproc,"Total number of CPU used for calculation.\nwill be used as N in \"mpirun -np N vasp\"\nto start vasp calculation."); - VASP_SPIN_TABLE(vasp_gui.ncore,vasp_gui.calc.ncore,parallel_eq,"NCORE=",1,2,1,2); + GUI_SPIN_TABLE(table,vasp_gui.ncore,vasp_gui.calc.ncore,parallel_eq,"NCORE=",1,2,1,2); GUI_TOOLTIP(vasp_gui.ncore,"NCORE: Ch. 6.57 DEFAULT: 1\nSets how many cores works on one orbital.\nNote that NCORE is limited by KPAR."); - VASP_SPIN_TABLE(vasp_gui.kpar,vasp_gui.calc.kpar,parallel_eq,"KPAR=",2,3,1,2); + GUI_SPIN_TABLE(table,vasp_gui.kpar,vasp_gui.calc.kpar,parallel_eq,"KPAR=",2,3,1,2); GUI_TOOLTIP(vasp_gui.kpar,"KPAR: Ch. 6.57 DEFAULT: 1\nSets the number of k-points treated in parallel.\nEach k-point is worked on by NCORE CPUs."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lplane,NULL,"LPLANE",3,4,1,2);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lplane,NULL,"LPLANE",3,4,1,2);/*not calling anything*/ GUI_TOOLTIP(button,"LPLANE: Ch. 6.57 DEFAULT: TRUE\nIf set the real-space data distribution is done plane wise."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lscalu,NULL,"LSCALU",4,5,1,2);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lscalu,NULL,"LSCALU",4,5,1,2);/*not calling anything*/ GUI_TOOLTIP(button,"LSCALU: Ch. 6.59 DEFAULT: FALSE\nIf set parallel LU decomposition will be used."); - VASP_CHECK_TABLE(button,vasp_gui.calc.lscalapack,NULL,"LSCALAPACK",5,6,1,2);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,vasp_gui.calc.lscalapack,NULL,"LSCALAPACK",5,6,1,2);/*not calling anything*/ GUI_TOOLTIP(button,"LSCALAPACK: Ch. 6.59 DEFAULT: FALSE\nIf set scaLAPACK routines will be used."); /* --- end frame */ /* --- DISTANT */ @@ -3673,38 +3660,37 @@ GUI_TOOLTIP(button,"LSCALAPACK: Ch. 6.59 DEFAULT: FALSE\nIf set scaLAPACK routin /*create a vbox in frame*/ GUI_VBOX_FRAME(frame,vbox); /* 1st line */ - VASP_NEW_LINE(); + GUI_LINE_BOX(vbox,hbox); /* 2nd line */ - VASP_NEW_LINE(); - VASP_NEW_LABEL("Remote execution of VASP is currently UNDER CONSTRUCTION."); + GUI_LINE_BOX(vbox,hbox); + GUI_LABEL_BOX(hbox,label,"Remote execution of VASP is currently UNDER CONSTRUCTION."); /* 3rd line */ - VASP_NEW_LINE(); -// VASP_NEW_SEPARATOR(); - VASP_NEW_LABEL("For now, please save files and manually transfer them to the distant server, then submit and retreive files as usual."); + GUI_LINE_BOX(vbox,hbox); + GUI_LABEL_BOX(hbox,label,"For now, please save files and manually transfer them to the distant server, then submit and retreive files as usual."); /* 4th line */ - VASP_NEW_LINE(); - VASP_NEW_LABEL("The future GDIS job interface will hopefully automate the whole process..."); + GUI_LINE_BOX(vbox,hbox); + GUI_LABEL_BOX(hbox,label,"The future GDIS job interface will hopefully automate the whole process..."); /* 5th line */ - VASP_NEW_LINE(); - VASP_NEW_LABEL("...and will be made available in the VASP calculation interface at that time."); - VASP_NEW_SEPARATOR(); - VASP_NEW_LABEL("--OVHPA"); + GUI_LINE_BOX(vbox,hbox); + GUI_LABEL_BOX(hbox,label,"...and will be made available in the VASP calculation interface at that time."); + GUI_NEW_SEPARATOR(hbox,separator); + GUI_LABEL_BOX(hbox,label,"--OVHPA"); /* 6th line */ - VASP_NEW_LINE(); + GUI_LINE_BOX(vbox,hbox); +/* --- end frame */ /* --- Outside of notebook */ - GUI_FRAME_BOX(GTK_BOX(GTK_DIALOG(vasp_gui.window)->vbox),frame); + GUI_FRAME_WINDOW(vasp_gui.window,frame); GUI_VBOX_FRAME(frame,vbox); /* Action buttons */ - vasp_gui.button_save=gui_stock_button(GTK_STOCK_SAVE, save_vasp_calc, NULL, GTK_DIALOG(vasp_gui.window)->action_area); - vasp_gui.button_exec=gui_stock_button(GTK_STOCK_EXECUTE, exec_calc, NULL, GTK_DIALOG(vasp_gui.window)->action_area); - gui_stock_button(GTK_STOCK_CLOSE, quit_vasp_gui, dialog, GTK_DIALOG(vasp_gui.window)->action_area); + GUI_SAVE_ACTION(vasp_gui.window,vasp_gui.button_save,save_vasp_calc,NULL); + GUI_EXEC_ACTION(vasp_gui.window,vasp_gui.button_exec,exec_calc,NULL); + GUI_CLOSE_ACTION(vasp_gui.window,button,quit_vasp_gui,dialog); /* connect to signals */ - g_signal_connect(GTK_NOTEBOOK(notebook),"switch-page",GTK_SIGNAL_FUNC(vasp_gui_page_switch),NULL); - + GUI_PAGE_CHANGE(notebook,vasp_gui_page_switch,NULL); /* all done */ vasp_gui_refresh();/*refresh once more*/ - gtk_widget_show_all(vasp_gui.window); + GUI_SHOW(vasp_gui.window);/*display*/ sysenv.refresh_dialog=TRUE; } From 5ed414eb7ffe833e08dafd50f27b637ef30bdd48 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 26 Jul 2018 16:53:49 +0900 Subject: [PATCH 07/56] gui_uspex: prepare unified gui interface VII + fix memory leaks I. --- src/gui_defs.h | 31 ++++++- src/gui_vasp.c | 217 +++++++++++++++++++++++++++++-------------------- 2 files changed, 158 insertions(+), 90 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index 1aaf2db..d0c914f 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -52,16 +52,22 @@ The GNU GPL can also be found at http://www.gnu.org }while(0) /*Set a new text entry (entry) with initial value ("value") expanding (wilde=TRUE) or not (wilde=FALSE) in an horizontal box (hbox).*/ #define GUI_TEXT_ENTRY(hbox,entry,value,wilde) do{\ + gchar *_text;\ entry=gtk_entry_new();\ - if(value!=NULL) gtk_entry_set_text(GTK_ENTRY(entry),g_strdup_printf("%s",value));\ + _text=g_strdup_printf("%s",value);\ + if(value!=NULL) gtk_entry_set_text(GTK_ENTRY(entry),_text);\ gtk_box_pack_start(GTK_BOX(hbox), entry, wilde, wilde, 0);\ + g_free(_text);\ }while(0) /*Set a new entry (entry) with initial value (value) of format ("format") with a width of (size) characters, in an horizontal box (hbox).*/ #define GUI_ENTRY(hbox,entry,value,format,size) do{\ + gchar *_text;\ entry=gtk_entry_new();\ - gtk_entry_set_text(GTK_ENTRY(entry),g_strdup_printf(format,value));\ + _text=g_strdup_printf(format,value);\ + gtk_entry_set_text(GTK_ENTRY(entry),_text);\ gtk_entry_set_width_chars (GTK_ENTRY(entry),size);\ gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 0);\ + g_free(_text);\ }while(0) /*Set a new separator (separator) in an horizontal box (hbox).*/ #define GUI_NEW_SEPARATOR(hbox,separator) do{\ @@ -229,6 +235,23 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_COMBOBOX_SET(combobox,default_value) do{\ gtk_combo_box_set_active(GTK_COMBO_BOX(combobox),default_value);\ }while(0) +/*Get combobox (combobox) active index (index).*/ +#define GUI_COMBOBOX_GET(combobox,index) do{\ + index=gtk_combo_box_get_active(GTK_COMBO_BOX(combobox));\ +}while(0) +/*Get combobox (combobox) active text ("text")*/ +#define GUI_COMBOBOX_GET_TEXT(combobox,text) do{\ + text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(combobox));\ +}while(0) +/*Insert combobox (combobox) text ("text") at position index (index).*/ +/* NEW: use non-deprecated gtk_combo_box_text_insert_text */ +#define GUI_COMBOBOX_ADD_TEXT(combobox,index,text) do{\ + gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(combobox),index,text);\ +}while(0) +/*Delete combobox (combobox) text at position index (index)*/ +#define GUI_COMBOBOX_DEL(combobox,index) do{\ + gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(combobox),index);\ +}while(0) /*Create a new cell with: * a boxed spin button, which default value is 1 and interval is [1,100], and labeled with text ("caption"). * Due to limitation of GTK, value has to be of double type and not integer (event though it make little sense).*/ @@ -296,6 +319,10 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ /*set the entry (entry) text ("text")*/ #define GUI_ENTRY_TEXT(entry,text) gtk_entry_set_text(GTK_ENTRY(entry),text); /*connect entry (entry) on change with the function (function) passing data (data).*/ +/* NEW: GTK2 says that return text is const and shall not be freed, hence the g_strdup */ +#define GUI_ENTRY_GET_TEXT(entry,text) do{\ + text=g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));\ +}while(0) #define GUI_ENTRY_CHANGE(entry,function,data) g_signal_connect(GTK_OBJECT(GTK_ENTRY(entry)),"changed",GTK_SIGNAL_FUNC(function),data) /*set sensitivity of a widget*/ #define GUI_LOCK(widget) gtk_widget_set_sensitive(widget,FALSE) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 02027c1..f544d53 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -1287,37 +1287,37 @@ void vasp_isif_selected(GtkWidget *w, struct model_pak *model){ vasp_gui.calc.isif=index; switch(index){ case 3://3:F_S_I_S_V - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_ions),TRUE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_shape),TRUE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_volume),TRUE); + GUI_TOGGLE_ON(vasp_gui.relax_ions); + GUI_TOGGLE_ON(vasp_gui.relax_shape); + GUI_TOGGLE_ON(vasp_gui.relax_volume); break; case 4://4:F_S_I_S_0 - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_ions),TRUE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_shape),TRUE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_volume),FALSE); + GUI_TOGGLE_ON(vasp_gui.relax_ions); + GUI_TOGGLE_ON(vasp_gui.relax_shape); + GUI_TOGGLE_OFF(vasp_gui.relax_volume); break; case 5://5:F_S_0_S_0 - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_ions),FALSE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_shape),TRUE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_volume),FALSE); + GUI_TOGGLE_OFF(vasp_gui.relax_ions); + GUI_TOGGLE_ON(vasp_gui.relax_shape); + GUI_TOGGLE_OFF(vasp_gui.relax_volume); break; case 6://6:F_S_0_S_V - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_ions),FALSE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_shape),TRUE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_volume),TRUE); + GUI_TOGGLE_OFF(vasp_gui.relax_ions); + GUI_TOGGLE_ON(vasp_gui.relax_shape); + GUI_TOGGLE_ON(vasp_gui.relax_volume); break; case 7://7:F_S_0_0_V - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_ions),FALSE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_shape),FALSE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_volume),TRUE); + GUI_TOGGLE_OFF(vasp_gui.relax_ions); + GUI_TOGGLE_OFF(vasp_gui.relax_shape); + GUI_TOGGLE_ON(vasp_gui.relax_volume); break; case 0://0:F_0_I_0_0 case 1://1:F_P_I_0_0 case 2://2:F_S_I_0_0 default: - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_ions),TRUE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_shape),FALSE); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_volume),FALSE); + GUI_TOGGLE_ON(vasp_gui.relax_ions); + GUI_TOGGLE_OFF(vasp_gui.relax_shape); + GUI_TOGGLE_OFF(vasp_gui.relax_volume); } } /****************/ @@ -1333,14 +1333,14 @@ else if ((!vasp_gui.rions)&&(vasp_gui.rshape)&&(vasp_gui.rvolume)) vasp_gui.calc else if ((!vasp_gui.rions)&&(!vasp_gui.rshape)&&(vasp_gui.rvolume)) vasp_gui.calc.isif=7; /*deal with forbiden combination*/ if((vasp_gui.rions)&&(!vasp_gui.rshape)&&(vasp_gui.rvolume)) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_ions),FALSE); + GUI_TOGGLE_OFF(vasp_gui.relax_ions); vasp_gui.calc.isif=7; } if((!vasp_gui.rions)&&(!vasp_gui.rshape)&&(!vasp_gui.rvolume)) { - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.relax_ions),TRUE); + GUI_TOGGLE_ON(vasp_gui.relax_ions); vasp_gui.calc.isif=2; } -gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.isif),vasp_gui.calc.isif);/*more simple than before*/ +GUI_COMBOBOX_SET(vasp_gui.isif,vasp_gui.calc.isif); } /*****************************/ /* selective dynamics toggle */ @@ -1348,31 +1348,40 @@ gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.isif),vasp_gui.calc.isif);/*more void toggle_poscar_sd(){ if((vasp_gui.calc.poscar_free==VPF_MAN)&&(vasp_gui.calc.poscar_sd)){ /*we need some tags*/ - gtk_widget_set_sensitive(vasp_gui.poscar_tx,TRUE); - gtk_widget_set_sensitive(vasp_gui.poscar_ty,TRUE); - gtk_widget_set_sensitive(vasp_gui.poscar_tz,TRUE); + GUI_UNLOCK(vasp_gui.poscar_tx); + GUI_UNLOCK(vasp_gui.poscar_ty); + GUI_UNLOCK(vasp_gui.poscar_tz); }else{ /*tags are no longer important*/ - gtk_widget_set_sensitive(vasp_gui.poscar_tx,FALSE); - gtk_widget_set_sensitive(vasp_gui.poscar_ty,FALSE); - gtk_widget_set_sensitive(vasp_gui.poscar_tz,FALSE); + GUI_LOCK(vasp_gui.poscar_tx); + GUI_LOCK(vasp_gui.poscar_ty); + GUI_LOCK(vasp_gui.poscar_tz); } - gtk_widget_set_sensitive(vasp_gui.poscar_free,vasp_gui.calc.poscar_sd); + if(vasp_gui.calc.poscar_sd) GUI_UNLOCK(vasp_gui.poscar_free); + else GUI_LOCK(vasp_gui.poscar_free); } /*************************/ /* selecting poscar_free */ /*************************/ void vasp_poscar_free_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gint ix=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms));/*PUSH*/ + gint index; + gint ix; gchar *text; gdouble x,y,z; gchar symbol[3]; gint idx=0; gchar tag; - gtk_widget_set_sensitive(vasp_gui.poscar_tx,(index==2)); - gtk_widget_set_sensitive(vasp_gui.poscar_ty,(index==2)); - gtk_widget_set_sensitive(vasp_gui.poscar_tz,(index==2)); + GUI_COMBOBOX_GET(w,index); + GUI_COMBOBOX_GET(vasp_gui.poscar_atoms,ix);/*PUSH*/ + if(index==2){ + GUI_UNLOCK(vasp_gui.poscar_tx); + GUI_UNLOCK(vasp_gui.poscar_ty); + GUI_UNLOCK(vasp_gui.poscar_tz); + }else{ + GUI_LOCK(vasp_gui.poscar_tx); + GUI_LOCK(vasp_gui.poscar_ty); + GUI_LOCK(vasp_gui.poscar_tz); + } switch(index){ case 0://All atom FIXED vasp_gui.calc.poscar_free=VPF_FIXED; @@ -1387,27 +1396,29 @@ void vasp_poscar_free_selected(GtkWidget *w, struct model_pak *model){ vasp_gui.calc.poscar_free=VPF_FREE; tag='T'; } - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); while(g_ascii_strcasecmp(text,"ADD atom")!=0){ /*modify each line tags*/ sscanf(text,"%lf %lf %lf %*c %*c %*c ! atom: %*i (%[^)])",&x,&y,&z,&(symbol[0])); - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx, - g_strdup_printf("%.8lf %.8lf %.8lf %c %c %c ! atom: %i (%s)", - x,y,z,tag,tag,tag,idx,symbol)); - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),idx+1); + g_free(text);/*combobox returned text should be freed*/ + text=g_strdup_printf("%.8lf %.8lf %.8lf %c %c %c ! atom: %i (%s)",x,y,z,tag,tag,tag,idx,symbol); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.poscar_atoms,idx,text); + GUI_COMBOBOX_DEL(vasp_gui.poscar_atoms,idx+1); idx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + g_free(text);/*so is g_strdup text*/ + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); } /*return to selected atom*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),ix);/*PULL*/ + g_free(text);/*free "ADD atom" string*/ + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,ix);/*PULL*/ } /************************/ /* poscar_direct toggle */ /************************/ void toggle_poscar_direct(){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms));/*PUSH*/ + gint index;//=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms));/*PUSH*/ gint idx=0; gchar *text; gchar *tamp; @@ -1416,6 +1427,7 @@ void toggle_poscar_direct(){ gdouble vx,vy,vz; gdouble wx,wy,wz; /* TODO: recalculate all positions on a single click */ + GUI_COMBOBOX_GET(vasp_gui.poscar_atoms,index);/*PUSH*/ /*mini sync*/ VASP_REG_VAL(poscar_a0,"%lf"); VASP_REG_VAL(poscar_ux,"%lf"); @@ -1437,12 +1449,13 @@ void toggle_poscar_direct(){ wy=vasp_gui.calc.poscar_wy*vasp_gui.calc.poscar_a0; wz=vasp_gui.calc.poscar_wz*vasp_gui.calc.poscar_a0; /**/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); while(g_ascii_strcasecmp(text,"ADD atom")!=0){ /*get each line*/ tamp=g_strdup(text);/*to get enough space*/ sscanf(text,"%lf %lf %lf %[^\n]",&x,&y,&z,tamp); + g_free(text); /*convert*/ if(vasp_gui.calc.poscar_direct){ /*was cartesian, now changed to direct*/ @@ -1456,37 +1469,47 @@ void toggle_poscar_direct(){ z=z*(uz+vz+wz); } /*rewrite data*/ - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx,g_strdup_printf("%.8lf %.8lf %.8lf %s",x,y,z,tamp)); - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),idx+1); + text=g_strdup_printf("%.8lf %.8lf %.8lf %s",x,y,z,tamp); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.poscar_atoms,idx,text); + GUI_COMBOBOX_DEL(vasp_gui.poscar_atoms,idx+1); g_free(tamp); + g_free(text); idx++; /*get new line*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); } - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),index);/*PULL*/ + g_free(text);/*free "ADD atom" string*/ + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,index);/*PULL*/ } /*************************/ /* selecting poscar atom */ /*************************/ void vasp_poscar_atoms_selected(GtkWidget *w, struct model_pak *model){ - /* using combobox*/ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(w)); + gint index; + gchar *text; gdouble x,y,z; gchar tx,ty,tz; gchar symbol[3]; - gtk_entry_set_text(GTK_ENTRY(vasp_gui.poscar_index),g_strdup_printf("%i",index)); + GUI_COMBOBOX_GET(w,index); + text=g_strdup_printf("%i",index); + GUI_ENTRY_TEXT(vasp_gui.poscar_index,text); + g_free(text); + GUI_COMBOBOX_GET_TEXT(w,text); if (g_ascii_strcasecmp(text,"ADD atom") == 0) { /*allow symbol*/ - gtk_widget_set_sensitive(vasp_gui.poscar_symbol,TRUE); - }else{ + GUI_UNLOCK(vasp_gui.poscar_symbol); + }else{ /*populate atom properties*/ sscanf(text,"%lf %lf %lf %c %c %c ! atom: %*i (%[^)])",&x,&y,&z,&tx,&ty,&tz,&(symbol[0])); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.poscar_symbol),g_strdup_printf("%s",symbol)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.poscar_x),g_strdup_printf("%.6lf",x)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.poscar_y),g_strdup_printf("%.6lf",y)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.poscar_z),g_strdup_printf("%.6lf",z)); + g_free(text);text=g_strdup_printf("%s",symbol); + GUI_ENTRY_TEXT(vasp_gui.poscar_symbol,text); + g_free(text);text=g_strdup_printf("%.6lf",x); + GUI_ENTRY_TEXT(vasp_gui.poscar_x,text); + g_free(text);text=g_strdup_printf("%.6lf",y); + GUI_ENTRY_TEXT(vasp_gui.poscar_y,text); + g_free(text);text=g_strdup_printf("%.6lf",z); + GUI_ENTRY_TEXT(vasp_gui.poscar_z,text); /* register all that */ vasp_gui.calc.poscar_index=index; vasp_gui.calc.poscar_x=x; @@ -1496,35 +1519,44 @@ void vasp_poscar_atoms_selected(GtkWidget *w, struct model_pak *model){ vasp_gui.calc.poscar_ty=(ty=='T'); vasp_gui.calc.poscar_tz=(tz=='T'); /* disallow symbol */ - gtk_widget_set_sensitive(vasp_gui.poscar_symbol,FALSE); + GUI_LOCK(vasp_gui.poscar_symbol); } + g_free(text); /* set tags sensitivity */ - gtk_widget_set_sensitive(vasp_gui.poscar_tx,(vasp_gui.calc.poscar_free==VPF_MAN)); - gtk_widget_set_sensitive(vasp_gui.poscar_ty,(vasp_gui.calc.poscar_free==VPF_MAN)); - gtk_widget_set_sensitive(vasp_gui.poscar_tz,(vasp_gui.calc.poscar_free==VPF_MAN)); + if(vasp_gui.calc.poscar_free==VPF_MAN){ + GUI_UNLOCK(vasp_gui.poscar_tx); + GUI_UNLOCK(vasp_gui.poscar_ty); + GUI_UNLOCK(vasp_gui.poscar_tz); + }else{ + GUI_LOCK(vasp_gui.poscar_tx); + GUI_LOCK(vasp_gui.poscar_ty); + GUI_LOCK(vasp_gui.poscar_tz); + } /* (re)set tags value! */ - if(vasp_gui.calc.poscar_tx) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.poscar_tx),TRUE); - else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.poscar_tx),FALSE); - if(vasp_gui.calc.poscar_ty) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.poscar_ty),TRUE); - else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.poscar_ty),FALSE); - if(vasp_gui.calc.poscar_tz) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.poscar_tz),TRUE); - else gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.poscar_tz),FALSE); + if(vasp_gui.calc.poscar_tx) GUI_TOGGLE_ON(vasp_gui.poscar_tx); + else GUI_TOGGLE_OFF(vasp_gui.poscar_tx); + if(vasp_gui.calc.poscar_ty) GUI_TOGGLE_ON(vasp_gui.poscar_ty); + else GUI_TOGGLE_OFF(vasp_gui.poscar_ty); + if(vasp_gui.calc.poscar_tz) GUI_TOGGLE_ON(vasp_gui.poscar_tz); + else GUI_TOGGLE_OFF(vasp_gui.poscar_tz); } /**************************/ /* modify/add poscar atom */ /**************************/ void vasp_atom_modified(){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + gint index; + gchar *text; gchar *tamp; gchar tx,ty,tz; - /*mini-sync*/ + GUI_COMBOBOX_GET(vasp_gui.poscar_atoms,index);/*PUSH*/ VASP_REG_VAL(poscar_index,"%i"); VASP_REG_VAL(poscar_x,"%lf"); VASP_REG_VAL(poscar_y,"%lf"); VASP_REG_VAL(poscar_z,"%lf"); - sprintf(vasp_gui.calc.poscar_symbol,"%s",gtk_entry_get_text(GTK_ENTRY(vasp_gui.poscar_symbol))); + GUI_ENTRY_GET_TEXT(vasp_gui.poscar_symbol,text); + sprintf(vasp_gui.calc.poscar_symbol,"%s",text); + g_free(text); tx='F'; ty='F'; tz='F'; @@ -1542,33 +1574,42 @@ void vasp_atom_modified(){ break; } /* add/modify */ + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); if(g_ascii_strcasecmp(text,"ADD atom") == 0){ /*we are going to insert some data*/ - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.poscar_atoms),index, - g_strdup_printf("%.8lf %.8lf %.8lf %c %c %c ! atom: %i (%s)", - vasp_gui.calc.poscar_x,vasp_gui.calc.poscar_y,vasp_gui.calc.poscar_z,tx,ty,tz,index,vasp_gui.calc.poscar_symbol)); + g_free(text); + text=g_strdup_printf("%.8lf %.8lf %.8lf %c %c %c ! atom: %i (%s)", + vasp_gui.calc.poscar_x,vasp_gui.calc.poscar_y,vasp_gui.calc.poscar_z,tx,ty,tz,index,vasp_gui.calc.poscar_symbol); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.poscar_atoms,index,text); }else{ /*we are goign to modify some data*/ - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.poscar_atoms),index, - g_strdup_printf("%.8lf %.8lf %.8lf %c %c %c ! atom: %i (%s)", - vasp_gui.calc.poscar_x,vasp_gui.calc.poscar_y,vasp_gui.calc.poscar_z,tx,ty,tz,index,vasp_gui.calc.poscar_symbol)); - /* Note: GTK 3.0 has gtk_combo_box_text_insert */ - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),index+1); + g_free(text); + text=g_strdup_printf("%.8lf %.8lf %.8lf %c %c %c ! atom: %i (%s)", + vasp_gui.calc.poscar_x,vasp_gui.calc.poscar_y,vasp_gui.calc.poscar_z,tx,ty,tz,index,vasp_gui.calc.poscar_symbol); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.poscar_atoms,index,text); + GUI_COMBOBOX_DEL(vasp_gui.poscar_atoms,index+1); } + g_free(text); /*re-select current entry (to refresh content)*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),index); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,index);/*PULL*/ vasp_gui.poscar_dirty=TRUE; } /**********************/ /* delete poscar atom */ /**********************/ void vasp_atom_delete(){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - if(g_ascii_strcasecmp(text,"ADD atom") == 0) return;/*can't delete this one*/ + gint index; + gchar *text; + GUI_COMBOBOX_GET(vasp_gui.poscar_atoms,index); if(index==-1) return;/*nothing selected anyway*/ - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),index); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),index-1); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); + if(g_ascii_strcasecmp(text,"ADD atom") == 0) { + g_free(text); + return;/*can't delete this one*/ + } + GUI_COMBOBOX_DEL(vasp_gui.poscar_atoms,index); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,index-1); + g_free(text); vasp_gui.poscar_dirty=TRUE; } /**************************/ From 32b3f5e19630b5b57436c7ed9671511f127b1ddc Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 26 Jul 2018 19:32:16 +0900 Subject: [PATCH 08/56] gui_uspex: prepare unified gui interface VIII + fix memory leaks II. --- src/gui_defs.h | 5 + src/gui_vasp.c | 508 +++++++++++++++++++++++++++++++------------------ 2 files changed, 327 insertions(+), 186 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index d0c914f..63625f7 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -260,9 +260,14 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ spin = gui_direct_spin(caption,&(value),1.0,100.0,1.0,function,NULL,_hbox);\ gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ }while(0) +/*Set spin (spin) within range [min,max] (min,max).*/ #define GUI_SPIN_RANGE(spin,min,max) do{\ gtk_spin_button_set_range(GTK_SPIN_BUTTON(spin),min,max);\ }while(0) +/*Set spin (spin) at value (value).*/ +#define GUI_SPIN_SET(spin,value) do{\ + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),value);\ +}while(0) /*Create a new cell with: * an open button (button) connected on click to function (function).*/ #define GUI_OPEN_BUTTON_TABLE(table,button,function,l,r,t,b) do{\ diff --git a/src/gui_vasp.c b/src/gui_vasp.c index f544d53..9935578 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -90,7 +90,9 @@ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filt char *filename; filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); if(filename) { - gtk_entry_set_text(GTK_ENTRY(vasp_gui.file_entry),g_strdup_printf("%s",filename)); + gchar *text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.file_entry,text); + g_free(text); vasprun_update(filename,&vasp_gui.calc);/*<- update everything according to the new vasprun.xml*/ g_free (filename); vasp_gui_refresh();/*refresh GUI with new vasp_gui.calc*/ @@ -115,7 +117,9 @@ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filt char *filename; filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); if(filename) { - gtk_entry_set_text(GTK_ENTRY(vasp_gui.job_mpirun),g_strdup_printf("%s",filename)); + gchar *text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.job_mpirun,text); + g_free(text); /* sync job_mpirun */ VASP_REG_TEXT(job_mpirun); g_free (filename); @@ -134,7 +138,9 @@ void load_vasp_exe_dialog(GtkButton *button, gpointer data){ char *filename; filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); if(filename) { - gtk_entry_set_text(GTK_ENTRY(vasp_gui.job_vasp_exe),g_strdup_printf("%s",filename)); + gchar *text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.job_vasp_exe,text); + g_free(text); /*sync job_vasp_exe*/ VASP_REG_TEXT(job_vasp_exe); g_free (filename); @@ -153,7 +159,9 @@ file_chooser=gtk_file_chooser_dialog_new("Select working folder",GTK_WINDOW(vasp { char *foldername = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); if(foldername) { - gtk_entry_set_text(GTK_ENTRY(vasp_gui.job_path),g_strdup_printf("%s",foldername)); + gchar *text=g_strdup_printf("%s",foldername); + GUI_ENTRY_TEXT(vasp_gui.job_path,text); + g_free(text); /*sync job_path*/ VASP_REG_TEXT(job_path); g_free (foldername); @@ -165,319 +173,446 @@ file_chooser=gtk_file_chooser_dialog_new("Select working folder",GTK_WINDOW(vasp /* refresh the GUI with value from vasp_gui.calc */ /*********************************************/ void vasp_gui_refresh(){ + gchar *text; /*do not refresh the simple interface, though*/ switch(vasp_gui.calc.prec){ case VP_SINGLE: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.prec),1);break; + GUI_COMBOBOX_SET(vasp_gui.prec,1);break; case VP_ACCURATE: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.prec),2);break; + GUI_COMBOBOX_SET(vasp_gui.prec,2);break; case VP_HIGH: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.prec),3);break; + GUI_COMBOBOX_SET(vasp_gui.prec,3);break; case VP_MED: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.prec),4);break; + GUI_COMBOBOX_SET(vasp_gui.prec,4);break; case VP_LOW: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.prec),5);break; + GUI_COMBOBOX_SET(vasp_gui.prec,5);break; case VP_NORM: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.prec),0); + GUI_COMBOBOX_SET(vasp_gui.prec,0); } //use_prec already sync - gtk_entry_set_text(GTK_ENTRY(vasp_gui.encut),g_strdup_printf("%.2lf",vasp_gui.calc.encut)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.enaug),g_strdup_printf("%.2lf",vasp_gui.calc.enaug)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ediff),g_strdup_printf("%.2lE",vasp_gui.calc.ediff)); + text=g_strdup_printf("%.2lf",vasp_gui.calc.encut); + GUI_ENTRY_TEXT(vasp_gui.encut,text); + g_free(text);text=g_strdup_printf("%.2lf",vasp_gui.calc.enaug); + GUI_ENTRY_TEXT(vasp_gui.enaug,text); + g_free(text);text=g_strdup_printf("%.2lE",vasp_gui.calc.ediff); + GUI_ENTRY_TEXT(vasp_gui.ediff,text); + g_free(text); switch(vasp_gui.calc.algo){ case VA_IALGO: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),1); + GUI_COMBOBOX_SET(vasp_gui.algo,1); switch(vasp_gui.calc.ialgo){ case VIA_OE_FIXED: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),0);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,0);break; case VIA_O_FIXED: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),1);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,1);break; case VIA_SUBROT: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),2);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,2);break; case VIA_STEEP: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),3);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,3);break; case VIA_CG: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),4);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,4);break; case VIA_PSTEEP: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),5);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,5);break; case VIA_PCG: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),6);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,6);break; case VIA_ESTEEP: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),8);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,8);break; case VIA_RMMP: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),9);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,9);break; case VIA_PRMM: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),10);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,10);break; case VIA_VAR_DAMP: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),11);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,11);break; case VIA_VAR_QUENCH: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),12);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,12);break; case VIA_VAR_PCG: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),13);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,13);break; case VIA_EXACT: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),14);break; + GUI_COMBOBOX_SET(vasp_gui.ialgo,14);break; case VIA_KOSUGI: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ialgo),7); + GUI_COMBOBOX_SET(vasp_gui.ialgo,7); } break; case VA_VERYFAST: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),2);break; + GUI_COMBOBOX_SET(vasp_gui.algo,2);break; case VA_FAST: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),3);break; + GUI_COMBOBOX_SET(vasp_gui.algo,3);break; case VA_CONJ: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),4);break; + GUI_COMBOBOX_SET(vasp_gui.algo,4);break; case VA_ALL: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),5);break; + GUI_COMBOBOX_SET(vasp_gui.algo,5);break; case VA_DAMPED: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),6);break; + GUI_COMBOBOX_SET(vasp_gui.algo,6);break; case VA_SUBROT: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),7);break; + GUI_COMBOBOX_SET(vasp_gui.algo,7);break; case VA_EIGEN: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),8);break; + GUI_COMBOBOX_SET(vasp_gui.algo,8);break; case VA_NONE: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),9);break; + GUI_COMBOBOX_SET(vasp_gui.algo,9);break; case VA_NOTHING: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),10);break; + GUI_COMBOBOX_SET(vasp_gui.algo,10);break; case VA_EXACT: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),11);break; + GUI_COMBOBOX_SET(vasp_gui.algo,11);break; case VA_DIAG: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),12);break; + GUI_COMBOBOX_SET(vasp_gui.algo,12);break; case VA_NORM: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.algo),0);break; + GUI_COMBOBOX_SET(vasp_gui.algo,0); } //ldiag already sync - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nsim),g_strdup_printf("%i",vasp_gui.calc.nsim)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.vtime),g_strdup_printf("%.4lf",vasp_gui.calc.vtime)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.iwavpr),g_strdup_printf("%i",vasp_gui.calc.iwavpr)); + text=g_strdup_printf("%i",vasp_gui.calc.nsim); + GUI_ENTRY_TEXT(vasp_gui.nsim,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.vtime); + GUI_ENTRY_TEXT(vasp_gui.vtime,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.iwavpr); + GUI_ENTRY_TEXT(vasp_gui.iwavpr,text); + g_free(text); //auto already sync - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nbands),g_strdup_printf("%i",vasp_gui.calc.nbands)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nelect),g_strdup_printf("%.4lf",vasp_gui.calc.nelect)); + text=g_strdup_printf("%i",vasp_gui.calc.nbands); + GUI_ENTRY_TEXT(vasp_gui.nbands,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.nelect); + GUI_ENTRY_TEXT(vasp_gui.nelect,text); + g_free(text); //iniwav already sync - gtk_entry_set_text(GTK_ENTRY(vasp_gui.istart),g_strdup_printf("%i",vasp_gui.calc.istart)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.icharg),g_strdup_printf("%i",vasp_gui.calc.icharg)); - /*mixer*/ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nelm),g_strdup_printf("%i",vasp_gui.calc.nelm)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nelmdl),g_strdup_printf("%i",vasp_gui.calc.nelmdl)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nelmin),g_strdup_printf("%i",vasp_gui.calc.nelmin)); + text=g_strdup_printf("%i",vasp_gui.calc.istart); + GUI_ENTRY_TEXT(vasp_gui.istart,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.icharg); + GUI_ENTRY_TEXT(vasp_gui.icharg,text); + g_free(text); + //mixer + text=g_strdup_printf("%i",vasp_gui.calc.nelm); + GUI_ENTRY_TEXT(vasp_gui.nelm,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.nelmdl); + GUI_ENTRY_TEXT(vasp_gui.nelmdl,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.nelmin); + GUI_ENTRY_TEXT(vasp_gui.nelmin,text); + g_free(text); if(!vasp_gui.calc.auto_mixer){ switch(vasp_gui.calc.imix){ case VM_0: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.mixer),0);break; + GUI_COMBOBOX_SET(vasp_gui.mixer,0);break; case VM_1: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.mixer),1);break; + GUI_COMBOBOX_SET(vasp_gui.mixer,1);break; case VM_2: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.mixer),2);break; + GUI_COMBOBOX_SET(vasp_gui.mixer,2);break; case VM_4: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.mixer),3); + GUI_COMBOBOX_SET(vasp_gui.mixer,3); } switch(vasp_gui.calc.inimix){ case VIM_0: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.inimix),0);break; + GUI_COMBOBOX_SET(vasp_gui.inimix,0);break; case VIM_1: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.inimix),1); + GUI_COMBOBOX_SET(vasp_gui.inimix,1); } switch(vasp_gui.calc.mixpre){ case VMP_0: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.mixpre),0);break; + GUI_COMBOBOX_SET(vasp_gui.mixpre,0);break; case VMP_2: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.mixpre),2);break; + GUI_COMBOBOX_SET(vasp_gui.mixpre,2);break; case VMP_1: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.mixpre),1); + GUI_COMBOBOX_SET(vasp_gui.mixpre,1); } } switch(vasp_gui.calc.lreal){ case VLR_AUTO: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lreal),0);break; + GUI_COMBOBOX_SET(vasp_gui.lreal,0);break; case VLR_ON: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lreal),1);break; + GUI_COMBOBOX_SET(vasp_gui.lreal,1);break; case VLR_TRUE: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lreal),2);break; + GUI_COMBOBOX_SET(vasp_gui.lreal,2);break; case VLR_FALSE: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lreal),3);break; + GUI_COMBOBOX_SET(vasp_gui.lreal,3); + } + if(vasp_gui.calc.ropt!=NULL){ + text=g_strdup_printf("%s",vasp_gui.calc.ropt); + GUI_ENTRY_TEXT(vasp_gui.ropt,text); + g_free(text); } - if(vasp_gui.calc.ropt!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.ropt),g_strdup_printf("%s",vasp_gui.calc.ropt)); //addgrid already sync - gtk_entry_set_text(GTK_ENTRY(vasp_gui.lmaxmix),g_strdup_printf("%i",vasp_gui.calc.lmaxmix)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.lmaxpaw),g_strdup_printf("%i",vasp_gui.calc.lmaxpaw)); + text=g_strdup_printf("%i",vasp_gui.calc.lmaxmix); + GUI_ENTRY_TEXT(vasp_gui.lmaxmix,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.lmaxpaw); + GUI_ENTRY_TEXT(vasp_gui.lmaxpaw,text); + g_free(text); if(!vasp_gui.calc.auto_grid){ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngx),g_strdup_printf("%i",vasp_gui.calc.ngx)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngy),g_strdup_printf("%i",vasp_gui.calc.ngy)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngz),g_strdup_printf("%i",vasp_gui.calc.ngz)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngxf),g_strdup_printf("%i",vasp_gui.calc.ngxf)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngyf),g_strdup_printf("%i",vasp_gui.calc.ngyf)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ngzf),g_strdup_printf("%i",vasp_gui.calc.ngzf)); - } - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ismear),g_strdup_printf("%i",vasp_gui.calc.ismear)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.sigma),g_strdup_printf("%.4lf",vasp_gui.calc.sigma)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.kgamma),vasp_gui.calc.kgamma); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kspacing),g_strdup_printf("%.4lf",vasp_gui.calc.kspacing)); - if(vasp_gui.calc.fermwe!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.fermwe),g_strdup_printf("%s",vasp_gui.calc.fermwe)); - if(vasp_gui.calc.fermdo!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.fermdo),g_strdup_printf("%s",vasp_gui.calc.fermdo)); + text=g_strdup_printf("%i",vasp_gui.calc.ngx); + GUI_ENTRY_TEXT(vasp_gui.ngx,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngy); + GUI_ENTRY_TEXT(vasp_gui.ngy,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngz); + GUI_ENTRY_TEXT(vasp_gui.ngz,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngxf); + GUI_ENTRY_TEXT(vasp_gui.ngxf,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngyf); + GUI_ENTRY_TEXT(vasp_gui.ngyf,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngzf); + GUI_ENTRY_TEXT(vasp_gui.ngzf,text); + g_free(text); + } + text=g_strdup_printf("%i",vasp_gui.calc.ismear); + GUI_ENTRY_TEXT(vasp_gui.ismear,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.sigma); + GUI_ENTRY_TEXT(vasp_gui.sigma,text); + g_free(text); + if(vasp_gui.calc.kgamma) GUI_TOGGLE_ON(vasp_gui.kgamma); + else GUI_TOGGLE_OFF(vasp_gui.kgamma); + text=g_strdup_printf("%.4lf",vasp_gui.calc.kspacing); + GUI_ENTRY_TEXT(vasp_gui.kspacing,text); + g_free(text); + if(vasp_gui.calc.fermwe!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.fermwe); + GUI_ENTRY_TEXT(vasp_gui.fermwe,text); + g_free(text); + } + if(vasp_gui.calc.fermdo!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.fermdo); + GUI_ENTRY_TEXT(vasp_gui.fermdo,text); + g_free(text); + } //ispin already sync //non_collinear already sync //lsorbit already sync //gga_compat already sync - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nupdown),g_strdup_printf("%.1lf",vasp_gui.calc.nupdown)); - if(vasp_gui.calc.magmom!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.magmom),g_strdup_printf("%s",vasp_gui.calc.magmom)); - if(vasp_gui.calc.saxis!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.saxis),g_strdup_printf("%s",vasp_gui.calc.saxis)); + text=g_strdup_printf("%.1lf",vasp_gui.calc.nupdown); + GUI_ENTRY_TEXT(vasp_gui.nupdown,text); + g_free(text); + if(vasp_gui.calc.magmom!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.magmom); + GUI_ENTRY_TEXT(vasp_gui.magmom,text); + g_free(text); + } + if(vasp_gui.calc.saxis!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.saxis); + GUI_ENTRY_TEXT(vasp_gui.saxis,text); + g_free(text); + } switch(vasp_gui.calc.gga){ case VG_91: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.gga),0);break; + GUI_COMBOBOX_SET(vasp_gui.gga,0);break; case VG_RP: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.gga),2);break; + GUI_COMBOBOX_SET(vasp_gui.gga,2);break; case VG_AM: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.gga),3);break; + GUI_COMBOBOX_SET(vasp_gui.gga,3);break; case VG_PS: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.gga),4);break; + GUI_COMBOBOX_SET(vasp_gui.gga,4);break; case VG_PE: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.gga),1); + GUI_COMBOBOX_SET(vasp_gui.gga,1); } //voskown already sync switch (vasp_gui.calc.mgga){ case VMG_TPSS: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.metagga),0);break; + GUI_COMBOBOX_SET(vasp_gui.metagga,0);break; case VMG_RTPSS: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.metagga),1);break; + GUI_COMBOBOX_SET(vasp_gui.metagga,1);break; case VMG_M06L: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.metagga),2);break; + GUI_COMBOBOX_SET(vasp_gui.metagga,2);break; case VMG_MBJ: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.metagga),3); + GUI_COMBOBOX_SET(vasp_gui.metagga,3); } //lmetagga already sync //lasph already sync //lmixtau already sync - gtk_entry_set_text(GTK_ENTRY(vasp_gui.lmaxtau),g_strdup_printf("%i",vasp_gui.calc.lmaxtau)); - if(vasp_gui.calc.cmbj!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.cmbj),g_strdup_printf("%s",vasp_gui.calc.cmbj)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.cmbja),g_strdup_printf("%.4lf",vasp_gui.calc.cmbja)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.cmbjb),g_strdup_printf("%.4lf",vasp_gui.calc.cmbjb)); + text=g_strdup_printf("%i",vasp_gui.calc.lmaxtau); + GUI_ENTRY_TEXT(vasp_gui.lmaxtau,text); + g_free(text); + if(vasp_gui.calc.cmbj!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.cmbj); + GUI_ENTRY_TEXT(vasp_gui.cmbj,text); + g_free(text); + } + text=g_strdup_printf("%.4lf",vasp_gui.calc.cmbja); + GUI_ENTRY_TEXT(vasp_gui.cmbja,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.cmbjb); + GUI_ENTRY_TEXT(vasp_gui.cmbjb,text); + g_free(text); if(vasp_gui.calc.ldau){ switch(vasp_gui.calc.ldau_type){ case VU_1: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ldau),0);break; + GUI_COMBOBOX_SET(vasp_gui.ldau,0);break; case VU_4: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ldau),2);break; + GUI_COMBOBOX_SET(vasp_gui.ldau,2);break; case VU_2: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ldau),1); + GUI_COMBOBOX_SET(vasp_gui.ldau,1); } switch(vasp_gui.calc.ldau_output){ case VUO_1: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ldau_print),1);break; + GUI_COMBOBOX_SET(vasp_gui.ldau_print,1);break; case VUO_2: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ldau_print),2);break; + GUI_COMBOBOX_SET(vasp_gui.ldau_print,2);break; case VUO_0: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ldau_print),0); + GUI_COMBOBOX_SET(vasp_gui.ldau_print,0); + } + if(vasp_gui.calc.ldaul!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.ldaul); + GUI_ENTRY_TEXT(vasp_gui.ldaul,text); + g_free(text); + } + if(vasp_gui.calc.ldauu!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.ldauu); + GUI_ENTRY_TEXT(vasp_gui.ldauu,text); + g_free(text); + } + if(vasp_gui.calc.ldauj!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.ldauj); + GUI_ENTRY_TEXT(vasp_gui.ldauj,text); + g_free(text); } - if(vasp_gui.calc.ldaul!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.ldaul),g_strdup_printf("%s",vasp_gui.calc.ldaul)); - if(vasp_gui.calc.ldauu!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.ldauu),g_strdup_printf("%s",vasp_gui.calc.ldauu)); - if(vasp_gui.calc.ldauj!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.ldauj),g_strdup_printf("%s",vasp_gui.calc.ldauj)); } switch(vasp_gui.calc.idipol){ case VID_1: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.idipol),1);break; + GUI_COMBOBOX_SET(vasp_gui.idipol,1);break; case VID_2: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.idipol),2);break; + GUI_COMBOBOX_SET(vasp_gui.idipol,2);break; case VID_3: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.idipol),3);break; + GUI_COMBOBOX_SET(vasp_gui.idipol,3);break; case VID_4: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.idipol),4);break; + GUI_COMBOBOX_SET(vasp_gui.idipol,4);break; case VID_0: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.idipol),0); + GUI_COMBOBOX_SET(vasp_gui.idipol,0); + } + if(vasp_gui.calc.ldipol) GUI_TOGGLE_ON(vasp_gui.ldipol); + else GUI_TOGGLE_OFF(vasp_gui.ldipol); + if(vasp_gui.calc.lmono) GUI_TOGGLE_ON(vasp_gui.lmono); + else GUI_TOGGLE_OFF(vasp_gui.lmono); + if(vasp_gui.calc.dipol!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.dipol); + GUI_ENTRY_TEXT(vasp_gui.dipol,text); + g_free(text); } - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.ldipol),vasp_gui.calc.ldipol); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.lmono),vasp_gui.calc.lmono); - if(vasp_gui.calc.dipol!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.dipol),g_strdup_printf("%s",vasp_gui.calc.dipol)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.epsilon),g_strdup_printf("%.4lf",vasp_gui.calc.epsilon)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.efield),g_strdup_printf("%.4lf",vasp_gui.calc.efield)); + text=g_strdup_printf("%.4lf",vasp_gui.calc.epsilon); + GUI_ENTRY_TEXT(vasp_gui.epsilon,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.efield); + GUI_ENTRY_TEXT(vasp_gui.efield,text); + g_free(text); switch(vasp_gui.calc.lorbit){ case 1: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lorbit),1);break; + GUI_COMBOBOX_SET(vasp_gui.lorbit,1);break; case 2: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lorbit),2);break; + GUI_COMBOBOX_SET(vasp_gui.lorbit,2);break; case 5: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lorbit),3);break; + GUI_COMBOBOX_SET(vasp_gui.lorbit,3);break; case 10: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lorbit),4);break; + GUI_COMBOBOX_SET(vasp_gui.lorbit,4);break; case 11: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lorbit),5);break; + GUI_COMBOBOX_SET(vasp_gui.lorbit,5);break; case 12: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lorbit),6);break; + GUI_COMBOBOX_SET(vasp_gui.lorbit,6);break; case 0: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.lorbit),0); - } - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nedos),g_strdup_printf("%i",vasp_gui.calc.nedos)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.emin),g_strdup_printf("%.2lf",vasp_gui.calc.emin)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.emax),g_strdup_printf("%.2lf",vasp_gui.calc.emax)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.efermi),g_strdup_printf("%.2lf",vasp_gui.calc.efermi)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.have_paw),vasp_gui.calc.have_paw); - if(vasp_gui.calc.rwigs!=NULL) gtk_entry_set_text(GTK_ENTRY(vasp_gui.rwigs),g_strdup_printf("%s",vasp_gui.calc.rwigs)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.loptics),vasp_gui.calc.loptics); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.lepsilon),vasp_gui.calc.lepsilon); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.lrpa),vasp_gui.calc.lrpa); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.lnabla),vasp_gui.calc.lnabla); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.cshift),g_strdup_printf("%.2lf",vasp_gui.calc.cshift)); + GUI_COMBOBOX_SET(vasp_gui.lorbit,0); + } + text=g_strdup_printf("%i",vasp_gui.calc.nedos); + GUI_ENTRY_TEXT(vasp_gui.nedos,text); + g_free(text);text=g_strdup_printf("%.2lf",vasp_gui.calc.emin); + GUI_ENTRY_TEXT(vasp_gui.emin,text); + g_free(text);text=g_strdup_printf("%.2lf",vasp_gui.calc.emax); + GUI_ENTRY_TEXT(vasp_gui.emax,text); + g_free(text);text=g_strdup_printf("%.2lf",vasp_gui.calc.efermi); + GUI_ENTRY_TEXT(vasp_gui.efermi,text); + g_free(text); + if(vasp_gui.calc.have_paw) GUI_TOGGLE_ON(vasp_gui.have_paw); + else GUI_TOGGLE_OFF(vasp_gui.have_paw); + if(vasp_gui.calc.rwigs!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.rwigs); + GUI_ENTRY_TEXT(vasp_gui.rwigs,text); + g_free(text); + } + if(vasp_gui.calc.loptics) GUI_TOGGLE_ON(vasp_gui.loptics); + else GUI_TOGGLE_OFF(vasp_gui.loptics); + if(vasp_gui.calc.lepsilon) GUI_TOGGLE_ON(vasp_gui.lepsilon); + else GUI_TOGGLE_OFF(vasp_gui.lepsilon); + if(vasp_gui.calc.lrpa) GUI_TOGGLE_ON(vasp_gui.lrpa); + else GUI_TOGGLE_OFF(vasp_gui.lrpa); + if(vasp_gui.calc.lnabla) GUI_TOGGLE_ON(vasp_gui.lnabla); + else GUI_TOGGLE_OFF(vasp_gui.lnabla); + text=g_strdup_printf("%.2lf",vasp_gui.calc.cshift); + GUI_ENTRY_TEXT(vasp_gui.cshift,text); + g_free(text); switch(vasp_gui.calc.ibrion){ case 0: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),1);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,1);break; case 1: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),2);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,2);break; case 2: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),3);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,3);break; case 3: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),4);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,4);break; case 5: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),5);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,5);break; case 6: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),6);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,6);break; case 7: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),7);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,7);break; case 8: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),8);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,8);break; case 44: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),9);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,9);break; case -1: default: - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.ibrion),0);break; + GUI_COMBOBOX_SET(vasp_gui.ibrion,0); } - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.isif),vasp_gui.calc.isif); + GUI_COMBOBOX_SET(vasp_gui.isif,vasp_gui.calc.isif); //relax_ions already sync //relax_shape already sync //relax_volume already sync - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nsw),g_strdup_printf("%i",vasp_gui.calc.nsw)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ediffg),g_strdup_printf("%.2lE",vasp_gui.calc.ediffg)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potim),g_strdup_printf("%.4lf",vasp_gui.calc.potim)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.pstress),g_strdup_printf("%.4lf",vasp_gui.calc.pstress)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nfree),g_strdup_printf("%i",vasp_gui.calc.nfree)); + text=g_strdup_printf("%i",vasp_gui.calc.nsw); + GUI_ENTRY_TEXT(vasp_gui.nsw,text); + g_free(text);text=g_strdup_printf("%.2lE",vasp_gui.calc.ediffg); + GUI_ENTRY_TEXT(vasp_gui.ediffg,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.potim); + GUI_ENTRY_TEXT(vasp_gui.potim,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.pstress); + GUI_ENTRY_TEXT(vasp_gui.pstress,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.nfree); + GUI_ENTRY_TEXT(vasp_gui.nfree,text); + g_free(text); if(vasp_gui.calc.ibrion==0){ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.tebeg),g_strdup_printf("%.1lf",vasp_gui.calc.tebeg)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.teend),g_strdup_printf("%.1lf",vasp_gui.calc.teend)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.smass),g_strdup_printf("%.1lf",vasp_gui.calc.smass)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.nblock),g_strdup_printf("%i",vasp_gui.calc.nblock)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kblock),g_strdup_printf("%i",vasp_gui.calc.kblock)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.npaco),g_strdup_printf("%i",vasp_gui.calc.npaco)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.apaco),g_strdup_printf("%.4lf",vasp_gui.calc.apaco)); + text=g_strdup_printf("%.1lf",vasp_gui.calc.tebeg); + GUI_ENTRY_TEXT(vasp_gui.tebeg,text); + g_free(text);text=g_strdup_printf("%.1lf",vasp_gui.calc.teend); + GUI_ENTRY_TEXT(vasp_gui.teend,text); + g_free(text);text=g_strdup_printf("%.1lf",vasp_gui.calc.smass); + GUI_ENTRY_TEXT(vasp_gui.smass,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.nblock); + GUI_ENTRY_TEXT(vasp_gui.nblock,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.kblock); + GUI_ENTRY_TEXT(vasp_gui.kblock,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.npaco); + GUI_ENTRY_TEXT(vasp_gui.npaco,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.apaco); + GUI_ENTRY_TEXT(vasp_gui.apaco,text); + g_free(text); } /*POSCAR*/ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.poscar_species),g_strdup_printf("%s",vasp_gui.calc.species_symbols)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.simple_poscar),g_strdup_printf("%s",vasp_gui.calc.species_symbols)); + text=g_strdup_printf("%s",vasp_gui.calc.species_symbols); + GUI_ENTRY_TEXT(vasp_gui.poscar_species,text); + g_free(text);text=g_strdup_printf("%s",vasp_gui.calc.species_symbols); + GUI_ENTRY_TEXT(vasp_gui.simple_poscar,text); + g_free(text); /*KPOINTS*/ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ismear_3),g_strdup_printf("%i",vasp_gui.calc.ismear)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.kgamma_3),vasp_gui.calc.kgamma); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kspacing_3),g_strdup_printf("%.4lf",vasp_gui.calc.kspacing)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_nkpts),g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts)); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_mode),vasp_gui.calc.kpoints_mode); + text=g_strdup_printf("%i",vasp_gui.calc.ismear); + GUI_ENTRY_TEXT(vasp_gui.ismear_3,text); + g_free(text); + if(vasp_gui.calc.kgamma) GUI_TOGGLE_ON(vasp_gui.kgamma_3); + else GUI_TOGGLE_OFF(vasp_gui.kgamma_3); + text=g_strdup_printf("%.4lf",vasp_gui.calc.kspacing); + GUI_ENTRY_TEXT(vasp_gui.kspacing_3,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts); + GUI_ENTRY_TEXT(vasp_gui.kpoints_nkpts,text); + g_free(text); + if(vasp_gui.calc.kpoints_mode) GUI_TOGGLE_ON(vasp_gui.kpoints_mode); + else GUI_TOGGLE_OFF(vasp_gui.kpoints_mode); switch(vasp_gui.calc.kpoints_mode){ case VKP_MAN: /*we do not update the kpoint list (here)*/ @@ -486,38 +621,38 @@ void vasp_gui_refresh(){ /*we do not update the kpoint list (here)*/ break; case VKP_GAMMA: - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kx),vasp_gui.calc.kpoints_kx); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_ky),vasp_gui.calc.kpoints_ky); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kz),vasp_gui.calc.kpoints_kz); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_sx),g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sx)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_sy),g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sy)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_sz),g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sz)); + GUI_SPIN_SET(vasp_gui.kpoints_kx,vasp_gui.calc.kpoints_kx); + GUI_SPIN_SET(vasp_gui.kpoints_ky,vasp_gui.calc.kpoints_ky); + GUI_SPIN_SET(vasp_gui.kpoints_kz,vasp_gui.calc.kpoints_kz); + text=g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sx); + GUI_ENTRY_TEXT(vasp_gui.kpoints_sx,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sy); + GUI_ENTRY_TEXT(vasp_gui.kpoints_sy,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sz); + GUI_ENTRY_TEXT(vasp_gui.kpoints_sz,text); + g_free(text); break; case VKP_MP: - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kx),vasp_gui.calc.kpoints_kx); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_ky),vasp_gui.calc.kpoints_ky); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kz),vasp_gui.calc.kpoints_kz); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_sx),g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sx)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_sy),g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sy)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_sz),g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sz)); + GUI_SPIN_SET(vasp_gui.kpoints_kx,vasp_gui.calc.kpoints_kx); + GUI_SPIN_SET(vasp_gui.kpoints_ky,vasp_gui.calc.kpoints_ky); + GUI_SPIN_SET(vasp_gui.kpoints_kz,vasp_gui.calc.kpoints_kz); + text=g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sx); + GUI_ENTRY_TEXT(vasp_gui.kpoints_sx,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sy); + GUI_ENTRY_TEXT(vasp_gui.kpoints_sy,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.kpoints_sz); + GUI_ENTRY_TEXT(vasp_gui.kpoints_sz,text); + g_free(text); break; case VKP_BASIS: /*we do not update the basis definition list (here)*/ break; case VKP_AUTO: default: - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kx),vasp_gui.calc.kpoints_kx); + GUI_SPIN_SET(vasp_gui.kpoints_kx,vasp_gui.calc.kpoints_kx); } /*skip POTCAR*/ /*skip EXEC*/ - -/* - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ismear),g_strdup_printf("%i",vasp_gui.calc.ismear)); - gtk_combo_box_set_active(GTK_COMBO_BOX(combobox),default_value); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.have_tetra),TRUE); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.ncore),1.0); -*/ - } /************************************************************/ /* Preload with default parameter from the simple interface */ @@ -1612,6 +1747,7 @@ void vasp_atom_delete(){ g_free(text); vasp_gui.poscar_dirty=TRUE; } +/* XXX XXX XXX HERE XXX XXX XXX */ /**************************/ /* selecting kpoints_mode */ /**************************/ From daabb4917164d154d55c65c069c4a36d878a249a Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 26 Jul 2018 19:42:42 +0900 Subject: [PATCH 09/56] gui_uspex: FIX: prepare unified gui interface VII. --- src/gui_vasp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 9935578..129dc37 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -611,8 +611,7 @@ void vasp_gui_refresh(){ g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts); GUI_ENTRY_TEXT(vasp_gui.kpoints_nkpts,text); g_free(text); - if(vasp_gui.calc.kpoints_mode) GUI_TOGGLE_ON(vasp_gui.kpoints_mode); - else GUI_TOGGLE_OFF(vasp_gui.kpoints_mode); + GUI_COMBOBOX_SET(vasp_gui.kpoints_mode,vasp_gui.calc.kpoints_mode); switch(vasp_gui.calc.kpoints_mode){ case VKP_MAN: /*we do not update the kpoint list (here)*/ From ea66d6a6ca2dc34d4adf59ea61aff76b1c745e94 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 27 Jul 2018 12:13:27 +0900 Subject: [PATCH 10/56] gui_uspex: prepare unified gui interface IX + fix memory leaks III. --- src/gui_defs.h | 8 +++ src/gui_vasp.c | 173 +++++++++++++++++++++++++------------------------ 2 files changed, 97 insertions(+), 84 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index 63625f7..c4f0b22 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -104,6 +104,14 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ gtk_container_set_border_width(GTK_CONTAINER(_absurd),1);\ gtk_box_pack_start(GTK_BOX(box),_absurd,TRUE,TRUE,0);\ }while(0) +/*Set text ("text") in textbuffer (tv_buffer)*/ +#define GUI_TEXTVIEW_SET(tv_buffer,text) do{\ + gtk_text_buffer_set_text(tv_buffer,text,-1);\ +}while(0) +/*Insert text ("text") in textbuffer (tv_buffer) - at cursor.*/ +#define GUI_TEXTVIEW_INSERT(tv_buffer,text) do{\ + gtk_text_buffer_insert_at_cursor(tv_buffer,text,-1);\ +}while(0) /**********************/ /* NOTEBOOK INTERFACE */ /**********************/ diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 129dc37..982603a 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -658,19 +658,23 @@ void vasp_gui_refresh(){ /************************************************************/ void vasp_apply_simple(GtkButton *button, gpointer data){ /*simple interface*/ -#define _OUT(a) gtk_text_buffer_insert_at_cursor(vasp_gui.simple_message_buff,a,-1) - gint calcul=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.simple_calcul)); - gint system=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.simple_system)); - gint kgrid=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.simple_kgrid)); + gint calcul; + gint system; + gint kgrid; gint dim=(gint)vasp_gui.dimension; - gtk_text_buffer_set_text(vasp_gui.simple_message_buff,"Simple interface started.\n",-1); + gchar *text; + /**/ + GUI_COMBOBOX_GET(vasp_gui.simple_calcul,calcul); + GUI_COMBOBOX_GET(vasp_gui.simple_system,system); + GUI_COMBOBOX_GET(vasp_gui.simple_kgrid,kgrid); + GUI_TEXTVIEW_SET(vasp_gui.simple_message_buff,"Simple interface started.\n"); /*1st take care of the obvious*/ if((vasp_gui.simple_rgeom)&&(calcul<3)){ - _OUT("FAIL: ROUGHT GEOMETRY: OPTIMIZE GEOMETRY FIRST!\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"FAIL: ROUGHT GEOMETRY: OPTIMIZE GEOMETRY FIRST!\n"); return; } if(dim==0){ - _OUT("ATOM/MOLECULE in a box, setting only gamma point\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"ATOM/MOLECULE in a box, setting only gamma point\n"); vasp_gui.calc.kpoints_mode=VKP_GAMMA; vasp_gui.calc.kpoints_kx=1.; vasp_gui.calc.kpoints_ky=1.; @@ -678,71 +682,72 @@ void vasp_apply_simple(GtkButton *button, gpointer data){ }else{ vasp_gui.calc.kpoints_mode=VKP_AUTO; vasp_gui.calc.kpoints_kx = (gdouble)(dim+dim*(1+2*(2*kgrid+1)));/*not a serious formula*/ - gtk_text_buffer_insert_at_cursor(vasp_gui.simple_message_buff, - g_strdup_printf("SET AUTO gamma-centered grid w/ AUTO = %i\n",(gint)vasp_gui.calc.kpoints_kx),-1); + text=g_strdup_printf("SET AUTO gamma-centered grid w/ AUTO = %i\n",(gint)vasp_gui.calc.kpoints_kx); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,text); + g_free(text); } if(calcul<3){ vasp_gui.calc.prec=VP_ACCURATE; - _OUT("SET PREC=ACCURATE\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET PREC=ACCURATE\n"); vasp_gui.calc.algo=VA_NORM; - _OUT("SET ALGO=NORMAL\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ALGO=NORMAL\n"); vasp_gui.calc.ldiag=TRUE; - _OUT("SET LDIAG=.TRUE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LDIAG=.TRUE.\n"); } vasp_gui.calc.use_prec=TRUE; /*set LREAL*/ if(vasp_gui.calc.atoms_total>16) { vasp_gui.calc.lreal=VLR_AUTO; - _OUT("SET LREAL=Auto\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LREAL=Auto\n"); } else { vasp_gui.calc.lreal=VLR_FALSE; - _OUT("SET LREAL=.FALSE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LREAL=.FALSE.\n"); } /*set smearing*/ if(system>0) { vasp_gui.calc.ismear=0; - _OUT("SET ISMEAR=0\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ISMEAR=0\n"); vasp_gui.calc.sigma=0.05; - _OUT("SET SIGMA=0.05\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET SIGMA=0.05\n"); } else { vasp_gui.calc.ismear=1; - _OUT("SET ISMEAR=1\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ISMEAR=1\n"); vasp_gui.calc.sigma=0.2; - _OUT("SET SIGMA=0.2\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET SIGMA=0.2\n"); } /*set dipol correction*/ - _OUT("Please manually SET all dipole related settings in ELECT-I!\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"Please manually SET all dipole related settings in ELECT-I!\n"); switch(dim){ case 0://atom in a box vasp_gui.calc.idipol=VID_4; - _OUT("SET IDIPOL=4\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET IDIPOL=4\n"); break; case 1: //linear system is characterized by a major axis vasp_gui.calc.idipol=VID_3; - _OUT("SET IDIPOL=3\n"); - _OUT("By convention, the major direction for a 1D material is the Z axis.\n"); - _OUT("If this is not the case, RESET IDIPOL accordingly!\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET IDIPOL=3\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"By convention, the major direction for a 1D material is the Z axis.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"If this is not the case, RESET IDIPOL accordingly!\n"); break; case 2: //surface are characterized by a normal axis vasp_gui.calc.idipol=VID_3; - _OUT("SET IDIPOL=3\n"); - _OUT("By convention, the Z AXIS is normal to the surface of 2D material.\n"); - _OUT("If this is not the case, RESET IDIPOL accordingly!\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET IDIPOL=3\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"By convention, the Z AXIS is normal to the surface of 2D material.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"If this is not the case, RESET IDIPOL accordingly!\n"); break; case 3: default: vasp_gui.calc.ldipol=FALSE; - _OUT("SET LDIPOL=.FALSE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LDIPOL=.FALSE.\n"); } /* spin? */ if((gint)(vasp_gui.calc.electron_total/2)-(gdouble)(vasp_gui.calc.electron_total/2.0)!=0.0){ vasp_gui.calc.ispin=TRUE; - _OUT("SET ISPIN=2\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ISPIN=2\n"); }else{ vasp_gui.calc.ispin=FALSE; - _OUT("SET ISPIN=1\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ISPIN=1\n"); } /*set calculation specific*/ switch(calcul){ @@ -750,143 +755,143 @@ void vasp_apply_simple(GtkButton *button, gpointer data){ /*use ismear=-5 if we have enough kpoints (ie more than 3)*/ if((kgrid>1)&&(dim>0)) { vasp_gui.calc.ismear=-5; - _OUT("SET ISMEAR=-5\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ISMEAR=-5\n"); } break; case 1://DOS/BANDS (single point) - if(dim==0) _OUT("PB: COARSE KGRID BUT BAND/DOS REQUIRED!\n"); + if(dim==0) GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"PB: COARSE KGRID BUT BAND/DOS REQUIRED!\n"); if(vasp_gui.calc.have_paw) { vasp_gui.calc.lorbit=12; - _OUT("SET LORBIT=12\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LORBIT=12\n"); } else { vasp_gui.calc.lorbit=2; - _OUT("SET LORBIT=2\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LORBIT=2\n"); } vasp_gui.calc.nedos=2001; - _OUT("SET NEDOS=2001\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NEDOS=2001\n"); vasp_gui.calc.emin=-10.; - _OUT("SET EMIN=-10.0\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET EMIN=-10.0\n"); vasp_gui.calc.emax=10.; - _OUT("SET EMAX=10.0\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET EMAX=10.0\n"); break; case 2://Lattice Dynamics (opt.) vasp_gui.calc.addgrid=TRUE; - _OUT("SET ADDGRID=.TRUE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ADDGRID=.TRUE.\n"); /*according to vasp manual, Sec. 9.9*/ //PREC=Accurate already set vasp_gui.calc.lreal=VLR_FALSE;/*force LREAL=FALSE*/ - _OUT("SET LREAL=.FALSE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LREAL=.FALSE.\n"); //smearing default vasp_gui.calc.ibrion=6; - _OUT("Default to finite Difference (IBRION=6)... SET IBRION=8 for Linear Perturbation!\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff, + "Default to finite Difference (IBRION=6)... SET IBRION=8 for Linear Perturbation!\n"); /*according to vasp manual, Sec. 6.22.6*/ vasp_gui.calc.potim=0.015; - _OUT("SET POTIM=0.015\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET POTIM=0.015\n"); if(vasp_gui.calc.ncore>1){ - _OUT("Lattice Dynamics does not support NCORE>1... RESETING NCORE\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"Lattice Dynamics does not support NCORE>1... RESETING NCORE\n"); vasp_gui.calc.ncore=1; - _OUT("(note that kpar can be set > 1\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"(note that kpar can be set > 1\n"); } break; case 3://Geometry (opt.) if(vasp_gui.simple_rgeom){ vasp_gui.calc.prec=VP_NORM; - _OUT("SET PREC=NORMAL\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET PREC=NORMAL\n"); vasp_gui.calc.use_prec=TRUE; vasp_gui.calc.algo=VA_FAST; - _OUT("SET ALGO=FAST\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ALGO=FAST\n"); /*according to vasp manual, Sec. 6.2.4*/ vasp_gui.calc.nelmin=5; - _OUT("SET NELMIN=5\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NELMIN=5\n"); vasp_gui.calc.ediff=1E-2; - _OUT("SET EDIFF=1E-2\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET EDIFF=1E-2\n"); vasp_gui.calc.ediffg=-0.3; - _OUT("SET EDIFFG=-0.3\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET EDIFFG=-0.3\n"); vasp_gui.calc.nsw=10; - _OUT("SET NSW=10\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NSW=10\n"); vasp_gui.calc.ibrion=2; - _OUT("SET IBRION=2\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET IBRION=2\n"); }else{ vasp_gui.calc.prec=VP_ACCURATE; - _OUT("SET PREC=ACCURATE\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET PREC=ACCURATE\n"); vasp_gui.calc.use_prec=TRUE; vasp_gui.calc.algo=VA_NORM; - _OUT("SET ALGO=NORMAL\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ALGO=NORMAL\n"); vasp_gui.calc.ldiag=TRUE; - _OUT("SET LDIAG=.TRUE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LDIAG=.TRUE.\n"); vasp_gui.calc.addgrid=TRUE; - _OUT("SET ADDGRID=.TRUE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ADDGRID=.TRUE.\n"); /*according to manual, Sec. 6.2.5*/ vasp_gui.calc.nelmin=8; - _OUT("SET NELMIN=8\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NELMIN=8\n"); vasp_gui.calc.ediff=1E-5; - _OUT("SET EDIFF=1E-5\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET EDIFF=1E-5\n"); vasp_gui.calc.ediffg=-0.01; - _OUT("SET EDIFFG=-0.01\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET EDIFFG=-0.01\n"); vasp_gui.calc.nsw=20; - _OUT("SET NSW=20\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NSW=20\n"); vasp_gui.calc.maxmix=80; - _OUT("SET MAXMIX=80\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET MAXMIX=80\n"); vasp_gui.calc.ibrion=1; - _OUT("SET IBRION=1\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET IBRION=1\n"); vasp_gui.calc.nfree=10; - _OUT("SET NFREE=10\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NFREE=10\n"); } break; case 4://Molecular Dynamics (opt.) if(vasp_gui.simple_rgeom) { vasp_gui.calc.prec=VP_LOW; - _OUT("SET PREC=LOW\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET PREC=LOW\n"); } else { vasp_gui.calc.prec=VP_NORM; - _OUT("SET PREC=NROMAL\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET PREC=NROMAL\n"); } vasp_gui.calc.use_prec=TRUE;/*<- this is maybe too high for PREC=NORMAL*/ /*according to vasp manual, Sec. 9.7*/ vasp_gui.calc.ediff=1E-5; - _OUT("SET EDIFF=1E-5\n"); - _OUT("Please set smearing manually!\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET EDIFF=1E-5\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"Please set smearing manually!\n"); vasp_gui.calc.ismear=-1; - _OUT("SET ISMEAR=-1\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ISMEAR=-1\n"); vasp_gui.calc.sigma=0.086; - _OUT("SET SIGMA=0.086\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET SIGMA=0.086\n"); /*choose smearing wisely*/ vasp_gui.calc.algo=VA_VERYFAST; - _OUT("SET ALGO=VERYFAST"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ALGO=VERYFAST"); vasp_gui.calc.maxmix=40; - _OUT("SET MAXMIX=40\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET MAXMIX=40\n"); vasp_gui.calc.isym=0; - _OUT("SET ISYM=0\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET ISYM=0\n"); vasp_gui.calc.nelmin=4; - _OUT("SET NELMIN=4\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NELMIN=4\n"); vasp_gui.calc.ibrion=0; - _OUT("SET IBRION=0\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET IBRION=0\n"); vasp_gui.calc.nsw=100; - _OUT("SET NSW=100\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NSW=100\n"); vasp_gui.calc.nwrite=0;/*TODO: for (adv.)*/ - _OUT("SET NWRITE=0\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NWRITE=0\n"); vasp_gui.calc.lcharg=FALSE; - _OUT("SET LCHARG=.FALSE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LCHARG=.FALSE.\n"); vasp_gui.calc.lwave=FALSE; - _OUT("SET LWAVE=.FALSE.\n"); - _OUT("Please set TEBEG and TEEND manually!\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET LWAVE=.FALSE.\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"Please set TEBEG and TEEND manually!\n"); vasp_gui.calc.tebeg=1000; - _OUT("SET TEBEG=1000\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET TEBEG=1000\n"); vasp_gui.calc.teend=1000; - _OUT("SET TEEND=1000\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET TEEND=1000\n"); vasp_gui.calc.smass=3; - _OUT("SET SMASS=3\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET SMASS=3\n"); vasp_gui.calc.nblock=50; - _OUT("SET NBLOCK=50\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET NBLOCK=50\n"); vasp_gui.calc.potim=1.5; - _OUT("SET POTIM=1.5\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"SET POTIM=1.5\n"); break; default: - _OUT("FAIL: UNKNOWN CALCUL SETTING!\n"); + GUI_TEXTVIEW_INSERT(vasp_gui.simple_message_buff,"FAIL: UNKNOWN CALCUL SETTING!\n"); return; } - vasp_gui_refresh(); -#undef _OUT + vasp_gui_refresh();/*TODO: refresh the simple interface part that was changed*/ } /******************/ /* selecting PREC */ From 9c4b8f5fa0d7917bceb730aadb10fe5d1f7e214d Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 27 Jul 2018 18:39:23 +0900 Subject: [PATCH 11/56] gui_uspex: prepare unified gui interface X + fix memory leaks IV + minor fixes. --- src/gui_defs.h | 6 +- src/gui_vasp.c | 839 ++++++++++++++++++++++++++++--------------------- 2 files changed, 485 insertions(+), 360 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index c4f0b22..6a52cc3 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -332,11 +332,13 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ /*set the entry (entry) text ("text")*/ #define GUI_ENTRY_TEXT(entry,text) gtk_entry_set_text(GTK_ENTRY(entry),text); /*connect entry (entry) on change with the function (function) passing data (data).*/ -/* NEW: GTK2 says that return text is const and shall not be freed, hence the g_strdup */ +#define GUI_ENTRY_CHANGE(entry,function,data) g_signal_connect(GTK_OBJECT(GTK_ENTRY(entry)),"changed",GTK_SIGNAL_FUNC(function),data) +/*get the text ("text") of an entry (entry).*/ +/* NEW: GTK2 says that return text is const and shall not be freed, hence the g_strdup + * so text HAVE TO be freed after use.*/ #define GUI_ENTRY_GET_TEXT(entry,text) do{\ text=g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));\ }while(0) -#define GUI_ENTRY_CHANGE(entry,function,data) g_signal_connect(GTK_OBJECT(GTK_ENTRY(entry)),"changed",GTK_SIGNAL_FUNC(function),data) /*set sensitivity of a widget*/ #define GUI_LOCK(widget) gtk_widget_set_sensitive(widget,FALSE) #define GUI_UNLOCK(widget) gtk_widget_set_sensitive(widget,TRUE) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 982603a..311fd5e 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -122,7 +122,7 @@ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filt g_free(text); /* sync job_mpirun */ VASP_REG_TEXT(job_mpirun); - g_free (filename); + g_free (filename); } } gtk_widget_destroy (GTK_WIDGET(file_chooser)); @@ -143,7 +143,7 @@ void load_vasp_exe_dialog(GtkButton *button, gpointer data){ g_free(text); /*sync job_vasp_exe*/ VASP_REG_TEXT(job_vasp_exe); - g_free (filename); + g_free (filename); } } gtk_widget_destroy (GTK_WIDGET(file_chooser)); @@ -164,7 +164,7 @@ file_chooser=gtk_file_chooser_dialog_new("Select working folder",GTK_WINDOW(vasp g_free(text); /*sync job_path*/ VASP_REG_TEXT(job_path); - g_free (foldername); + g_free (foldername); } } gtk_widget_destroy (GTK_WIDGET(file_chooser)); @@ -175,21 +175,21 @@ file_chooser=gtk_file_chooser_dialog_new("Select working folder",GTK_WINDOW(vasp void vasp_gui_refresh(){ gchar *text; /*do not refresh the simple interface, though*/ - switch(vasp_gui.calc.prec){ - case VP_SINGLE: + switch(vasp_gui.calc.prec){ + case VP_SINGLE: GUI_COMBOBOX_SET(vasp_gui.prec,1);break; - case VP_ACCURATE: + case VP_ACCURATE: GUI_COMBOBOX_SET(vasp_gui.prec,2);break; - case VP_HIGH: + case VP_HIGH: GUI_COMBOBOX_SET(vasp_gui.prec,3);break; - case VP_MED: + case VP_MED: GUI_COMBOBOX_SET(vasp_gui.prec,4);break; - case VP_LOW: + case VP_LOW: GUI_COMBOBOX_SET(vasp_gui.prec,5);break; - case VP_NORM: - default: + case VP_NORM: + default: GUI_COMBOBOX_SET(vasp_gui.prec,0); - } + } //use_prec already sync text=g_strdup_printf("%.2lf",vasp_gui.calc.encut); GUI_ENTRY_TEXT(vasp_gui.encut,text); @@ -317,7 +317,7 @@ void vasp_gui_refresh(){ default: GUI_COMBOBOX_SET(vasp_gui.mixpre,1); } - } + } switch(vasp_gui.calc.lreal){ case VLR_AUTO: GUI_COMBOBOX_SET(vasp_gui.lreal,0);break; @@ -897,7 +897,8 @@ void vasp_apply_simple(GtkButton *button, gpointer data){ /* selecting PREC */ /******************/ void vasp_prec_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch (index){ case 1://Single vasp_gui.calc.prec=VP_SINGLE;break; @@ -918,12 +919,16 @@ void vasp_prec_selected(GtkWidget *w, struct model_pak *model){ /* Toggle use of automatic prec settings */ /*****************************************/ void prec_toggle(GtkWidget *w, GtkWidget *box){ + gchar *text; if(!(vasp_gui.calc.use_prec)){ /*switch to manual values*/ GUI_UNLOCK(vasp_gui.encut); GUI_UNLOCK(vasp_gui.enaug); - GUI_ENTRY_TEXT(vasp_gui.encut,g_strdup_printf("%.2lf",vasp_gui.calc.encut)); - GUI_ENTRY_TEXT(vasp_gui.enaug,g_strdup_printf("%.2lf",vasp_gui.calc.enaug)); + text=g_strdup_printf("%.2lf",vasp_gui.calc.encut); + GUI_ENTRY_TEXT(vasp_gui.encut,text); + g_free(text);text=g_strdup_printf("%.2lf",vasp_gui.calc.enaug); + GUI_ENTRY_TEXT(vasp_gui.enaug,text); + g_free(text); }else{ /*switch to automatic values*/ GUI_LOCK(vasp_gui.encut); @@ -936,7 +941,8 @@ void prec_toggle(GtkWidget *w, GtkWidget *box){ /* selecting ALGO */ /******************/ void vasp_algo_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.ialgo); switch(index){ case 1://USE_IALGO @@ -974,7 +980,8 @@ void vasp_algo_selected(GtkWidget *w, struct model_pak *model){ /* selecting IALGO */ /*******************/ void vasp_ialgo_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch(index){ case 0://2:FIXED ORB/1E vasp_gui.calc.ialgo=VIA_OE_FIXED;break; @@ -1013,6 +1020,7 @@ void vasp_ialgo_selected(GtkWidget *w, struct model_pak *model){ /* elec toggle */ /***************/ void elec_toggle(GtkWidget *w, GtkWidget *box){ + gchar *text; if(!(vasp_gui.calc.auto_elec)){ /*switch to manual values*/ GUI_UNLOCK(vasp_gui.nsim); @@ -1020,11 +1028,17 @@ void elec_toggle(GtkWidget *w, GtkWidget *box){ GUI_UNLOCK(vasp_gui.nbands); GUI_UNLOCK(vasp_gui.nelect); GUI_UNLOCK(vasp_gui.iwavpr); - GUI_ENTRY_TEXT(vasp_gui.nsim,g_strdup_printf("%i",vasp_gui.calc.nsim)); - GUI_ENTRY_TEXT(vasp_gui.vtime,g_strdup_printf("%.4lf",vasp_gui.calc.vtime)); - GUI_ENTRY_TEXT(vasp_gui.nbands,g_strdup_printf("%i",vasp_gui.calc.nbands)); - GUI_ENTRY_TEXT(vasp_gui.nelect,g_strdup_printf("%.4lf",vasp_gui.calc.nelect)); - GUI_ENTRY_TEXT(vasp_gui.iwavpr,g_strdup_printf("%i",vasp_gui.calc.iwavpr)); + text=g_strdup_printf("%i",vasp_gui.calc.nsim); + GUI_ENTRY_TEXT(vasp_gui.nsim,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.vtime); + GUI_ENTRY_TEXT(vasp_gui.vtime,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.nbands); + GUI_ENTRY_TEXT(vasp_gui.nbands,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.nelect); + GUI_ENTRY_TEXT(vasp_gui.nelect,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.iwavpr); + GUI_ENTRY_TEXT(vasp_gui.iwavpr,text); + g_free(text); }else{ /*switch to automatic values*/ GUI_LOCK(vasp_gui.nsim); @@ -1038,7 +1052,8 @@ void elec_toggle(GtkWidget *w, GtkWidget *box){ /* selecting LREAL */ /*******************/ void vasp_lreal_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch(index){ case 0://Auto vasp_gui.calc.lreal=VLR_AUTO;break; @@ -1055,36 +1070,45 @@ void vasp_lreal_selected(GtkWidget *w, struct model_pak *model){ /* grid toggle */ /***************/ void grid_toggle(GtkWidget *w, GtkWidget *box){ - if(!(vasp_gui.calc.auto_grid)){ - /*switch to manual values*/ + gchar *text; + if(!(vasp_gui.calc.auto_grid)){ + /*switch to manual values*/ GUI_UNLOCK(vasp_gui.ngx); GUI_UNLOCK(vasp_gui.ngy); GUI_UNLOCK(vasp_gui.ngz); GUI_UNLOCK(vasp_gui.ngxf); GUI_UNLOCK(vasp_gui.ngyf); GUI_UNLOCK(vasp_gui.ngzf); - GUI_ENTRY_TEXT(vasp_gui.ngx,g_strdup_printf("%i",vasp_gui.calc.ngx)); - GUI_ENTRY_TEXT(vasp_gui.ngy,g_strdup_printf("%i",vasp_gui.calc.ngy)); - GUI_ENTRY_TEXT(vasp_gui.ngz,g_strdup_printf("%i",vasp_gui.calc.ngz)); - GUI_ENTRY_TEXT(vasp_gui.ngxf,g_strdup_printf("%i",vasp_gui.calc.ngxf)); - GUI_ENTRY_TEXT(vasp_gui.ngyf,g_strdup_printf("%i",vasp_gui.calc.ngyf)); - GUI_ENTRY_TEXT(vasp_gui.ngzf,g_strdup_printf("%i",vasp_gui.calc.ngzf)); - }else{ - /*switch to automatic values*/ + text=g_strdup_printf("%i",vasp_gui.calc.ngx); + GUI_ENTRY_TEXT(vasp_gui.ngx,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngy); + GUI_ENTRY_TEXT(vasp_gui.ngy,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngz); + GUI_ENTRY_TEXT(vasp_gui.ngz,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngxf); + GUI_ENTRY_TEXT(vasp_gui.ngxf,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngyf); + GUI_ENTRY_TEXT(vasp_gui.ngyf,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.ngzf); + GUI_ENTRY_TEXT(vasp_gui.ngzf,text); + g_free(text); + }else{ + /*switch to automatic values*/ GUI_LOCK(vasp_gui.ngx); GUI_LOCK(vasp_gui.ngy); GUI_LOCK(vasp_gui.ngz); GUI_LOCK(vasp_gui.ngxf); GUI_LOCK(vasp_gui.ngyf); GUI_LOCK(vasp_gui.ngzf); - } + } } /***************************/ /* ismear value is changed */ /***************************/ void ismear_changed(GtkWidget *w, struct model_pak *model){ - const gchar *label = gtk_entry_get_text(GTK_ENTRY(w)); - sscanf(label,"%i",&(vasp_gui.calc.ismear)); + gchar *label; + GUI_ENTRY_GET_TEXT(w,label); + sscanf(label,"%i",&(vasp_gui.calc.ismear)); if(vasp_gui.calc.ismear==-5) { GUI_TOGGLE_ON(vasp_gui.have_tetra); GUI_UNLOCK(vasp_gui.have_tetra); @@ -1093,33 +1117,37 @@ void ismear_changed(GtkWidget *w, struct model_pak *model){ GUI_TOGGLE_OFF(vasp_gui.have_tetra); GUI_LOCK(vasp_gui.have_tetra); } + g_free(label); } /*****************************/ /* kspacing value is changed */ /*****************************/ void kspacing_changed(GtkWidget *w, struct model_pak *model){ - const gchar *label = gtk_entry_get_text(GTK_ENTRY(w)); - sscanf(label,"%lf",&(vasp_gui.calc.kspacing)); + gchar *label; + GUI_ENTRY_GET_TEXT(w,label); + sscanf(label,"%lf",&(vasp_gui.calc.kspacing)); + g_free(label); } /************************/ /* toggle LNONCOLLINEAR */ /************************/ void lnoncoll_toggle(GtkWidget *w, GtkWidget *box){ - /* unselecting LNONCOLLINEAR automatically unselect LSORBIT */ - if(!vasp_gui.calc.non_collinear) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.lsorbit),FALSE); + /* unselecting LNONCOLLINEAR automatically unselect LSORBIT */ + if(!vasp_gui.calc.non_collinear) GUI_TOGGLE_OFF(vasp_gui.lsorbit); } /******************/ /* toggle LSORBIT */ /******************/ void lsorbit_toggle(GtkWidget *w, GtkWidget *box){ /* LSORBIT automatically select LNONCOLLINEAR */ - if(vasp_gui.calc.lsorbit) gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.lnoncoll),TRUE); + if(vasp_gui.calc.lsorbit) GUI_TOGGLE_ON(vasp_gui.lnoncoll); } /*****************/ /* selecting GGA */ /*****************/ void vasp_gga_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch(index){ case 0://91:PW91 vasp_gui.calc.gga=VG_91;break; @@ -1138,7 +1166,8 @@ void vasp_gga_selected(GtkWidget *w, struct model_pak *model){ /* selecting METAGGA */ /*********************/ void vasp_metagga_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.cmbj); GUI_LOCK(vasp_gui.cmbja); GUI_LOCK(vasp_gui.cmbjb); @@ -1161,34 +1190,35 @@ void vasp_metagga_selected(GtkWidget *w, struct model_pak *model){ /* toggle LMETAGGA */ /*******************/ void metagga_toggle(GtkWidget *w, GtkWidget *box){ - if(!vasp_gui.calc.lmetagga){ - /*switch to manual values*/ + if(!vasp_gui.calc.lmetagga){ + /*switch to manual values*/ GUI_LOCK(vasp_gui.metagga); GUI_LOCK(vasp_gui.cmbj); GUI_LOCK(vasp_gui.cmbja); GUI_LOCK(vasp_gui.cmbjb); - }else{ - /*switch to automatic values*/ + }else{ + /*switch to automatic values*/ GUI_UNLOCK(vasp_gui.metagga); GUI_COMBOBOX_SET(vasp_gui.metagga,3);//MBJ (actually there is no default) GUI_UNLOCK(vasp_gui.cmbj); GUI_UNLOCK(vasp_gui.cmbja); GUI_UNLOCK(vasp_gui.cmbjb); - } + } } /*******************/ /* toggle L(S)DA+U */ /*******************/ void ldau_toggle(GtkWidget *w, GtkWidget *box){ - if(!vasp_gui.calc.ldau){ - /*switch to manual values*/ + gchar *text; + if(!vasp_gui.calc.ldau){ + /*switch to manual values*/ GUI_LOCK(vasp_gui.ldau); GUI_LOCK(vasp_gui.ldau_print); GUI_LOCK(vasp_gui.ldaul); GUI_LOCK(vasp_gui.ldauu); GUI_LOCK(vasp_gui.ldauj); - }else{ - /*switch to automatic values*/ + }else{ + /*switch to automatic values*/ GUI_UNLOCK(vasp_gui.ldau); GUI_UNLOCK(vasp_gui.ldau_print); GUI_UNLOCK(vasp_gui.ldaul); @@ -1196,14 +1226,30 @@ void ldau_toggle(GtkWidget *w, GtkWidget *box){ GUI_UNLOCK(vasp_gui.ldauj); GUI_COMBOBOX_SET(vasp_gui.ldau,1);//2:LSDA+U Dudarev GUI_COMBOBOX_SET(vasp_gui.ldau_print,0);//0:Silent - /*TODO: update ldaul, ldauu, ldauj*/ - } + /*mini-sync*/ + if(vasp_gui.calc.ldaul!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.ldaul); + GUI_ENTRY_TEXT(vasp_gui.ldaul,text); + g_free(text); + } + if(vasp_gui.calc.ldauu!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.ldauu); + GUI_ENTRY_TEXT(vasp_gui.ldauu,text); + g_free(text); + } + if(vasp_gui.calc.ldauj!=NULL) { + text=g_strdup_printf("%s",vasp_gui.calc.ldauj); + GUI_ENTRY_TEXT(vasp_gui.ldauj,text); + g_free(text); + } + } } /***************************/ /* selecting L(S)DA+U type */ /***************************/ void vasp_ldau_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch(index){ case 0://1:LSDA+U Liechtenstein vasp_gui.calc.ldau_type=VU_1;break; @@ -1218,7 +1264,8 @@ void vasp_ldau_selected(GtkWidget *w, struct model_pak *model){ /* selecting L(S)DA+U output verbosity */ /***************************************/ void vasp_ldau_print_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch(index){ case 1://1:Occupancy matrix vasp_gui.calc.ldau_output=VUO_1;break; @@ -1233,7 +1280,8 @@ void vasp_ldau_print_selected(GtkWidget *w, struct model_pak *model){ /* toggle manual selection of mixer */ /************************************/ void mixer_toggle(GtkWidget *w, GtkWidget *box){ - if((vasp_gui.calc.auto_mixer)){ + gchar *text; + if((vasp_gui.calc.auto_mixer)){ /*switch to manual values*/ GUI_LOCK(vasp_gui.mixer); GUI_LOCK(vasp_gui.amix); @@ -1245,8 +1293,8 @@ void mixer_toggle(GtkWidget *w, GtkWidget *box){ GUI_LOCK(vasp_gui.wc); GUI_LOCK(vasp_gui.inimix); GUI_LOCK(vasp_gui.mixpre); - }else{ - /*switch to automatic values*/ + }else{ + /*switch to automatic values*/ GUI_UNLOCK(vasp_gui.mixer); GUI_UNLOCK(vasp_gui.amix); GUI_UNLOCK(vasp_gui.bmix); @@ -1255,24 +1303,32 @@ void mixer_toggle(GtkWidget *w, GtkWidget *box){ GUI_UNLOCK(vasp_gui.bmix_mag); GUI_UNLOCK(vasp_gui.maxmix); GUI_COMBOBOX_SET(vasp_gui.mixer,3);//4:BROYDEN - GUI_ENTRY_TEXT(vasp_gui.amix,g_strdup_printf("%.4lf",vasp_gui.calc.amix)); - GUI_ENTRY_TEXT(vasp_gui.bmix,g_strdup_printf("%.4lf",vasp_gui.calc.bmix)); - GUI_ENTRY_TEXT(vasp_gui.amin,g_strdup_printf("%.4lf",vasp_gui.calc.amin)); - GUI_ENTRY_TEXT(vasp_gui.amix_mag,g_strdup_printf("%.4lf",vasp_gui.calc.amix_mag)); - GUI_ENTRY_TEXT(vasp_gui.bmix_mag,g_strdup_printf("%.4lf",vasp_gui.calc.bmix_mag)); - GUI_ENTRY_TEXT(vasp_gui.maxmix,g_strdup_printf("%i",vasp_gui.calc.maxmix)); + text=g_strdup_printf("%.4lf",vasp_gui.calc.amix); + GUI_ENTRY_TEXT(vasp_gui.amix,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.bmix); + GUI_ENTRY_TEXT(vasp_gui.bmix,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.amin); + GUI_ENTRY_TEXT(vasp_gui.amin,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.amix_mag); + GUI_ENTRY_TEXT(vasp_gui.amix_mag,text); + g_free(text);text=g_strdup_printf("%.4lf",vasp_gui.calc.bmix_mag); + GUI_ENTRY_TEXT(vasp_gui.bmix_mag,text); + g_free(text);text=g_strdup_printf("%i",vasp_gui.calc.maxmix); + GUI_ENTRY_TEXT(vasp_gui.maxmix,text); + g_free(text); if(vasp_gui.calc.imix==VM_4){ GUI_UNLOCK(vasp_gui.wc); GUI_UNLOCK(vasp_gui.inimix); GUI_UNLOCK(vasp_gui.mixpre); } - } + } } /*******************/ /* selecting mixer */ /*******************/ void vasp_mixer_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.wc); GUI_LOCK(vasp_gui.inimix); GUI_LOCK(vasp_gui.mixpre); @@ -1295,7 +1351,8 @@ void vasp_mixer_selected(GtkWidget *w, struct model_pak *model){ /* selecting initial mixer */ /***************************/ void vasp_inimix_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch(index){ case 0://0:LINEAR vasp_gui.calc.inimix=VIM_0;break; @@ -1308,7 +1365,8 @@ void vasp_inimix_selected(GtkWidget *w, struct model_pak *model){ /* selecting pre-mixing */ /************************/ void vasp_mixpre_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch(index){ case 0://0:NONE vasp_gui.calc.mixpre=VMP_0;break; @@ -1323,7 +1381,8 @@ void vasp_mixpre_selected(GtkWidget *w, struct model_pak *model){ /* selecting idipol */ /********************/ void vasp_idipol_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); GUI_UNLOCK(vasp_gui.ldipol); GUI_UNLOCK(vasp_gui.lmono); GUI_UNLOCK(vasp_gui.dipol); @@ -1354,7 +1413,8 @@ void vasp_idipol_selected(GtkWidget *w, struct model_pak *model){ /* selecting lorbit */ /********************/ void vasp_lorbit_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); switch(index){ case 1://1:lm-PROCAR vasp_gui.calc.lorbit=1;break; @@ -1377,25 +1437,26 @@ void vasp_lorbit_selected(GtkWidget *w, struct model_pak *model){ /* selecting ibrion */ /********************/ void vasp_ibrion_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); -GUI_LOCK(vasp_gui.tebeg); -GUI_LOCK(vasp_gui.teend); -GUI_LOCK(vasp_gui.smass); -GUI_LOCK(vasp_gui.nblock); -GUI_LOCK(vasp_gui.kblock); -GUI_LOCK(vasp_gui.npaco); -GUI_LOCK(vasp_gui.apaco); + gint index; + GUI_COMBOBOX_GET(w,index); + GUI_LOCK(vasp_gui.tebeg); + GUI_LOCK(vasp_gui.teend); + GUI_LOCK(vasp_gui.smass); + GUI_LOCK(vasp_gui.nblock); + GUI_LOCK(vasp_gui.kblock); + GUI_LOCK(vasp_gui.npaco); + GUI_LOCK(vasp_gui.apaco); switch(index){ case 1://0:Molecular Dynamics vasp_gui.calc.ibrion=0; /*molecular dynamics part*/ -GUI_UNLOCK(vasp_gui.tebeg); -GUI_UNLOCK(vasp_gui.teend); -GUI_UNLOCK(vasp_gui.smass); -GUI_UNLOCK(vasp_gui.nblock); -GUI_UNLOCK(vasp_gui.kblock); -GUI_UNLOCK(vasp_gui.npaco); -GUI_UNLOCK(vasp_gui.apaco); + GUI_UNLOCK(vasp_gui.tebeg); + GUI_UNLOCK(vasp_gui.teend); + GUI_UNLOCK(vasp_gui.smass); + GUI_UNLOCK(vasp_gui.nblock); + GUI_UNLOCK(vasp_gui.kblock); + GUI_UNLOCK(vasp_gui.npaco); + GUI_UNLOCK(vasp_gui.apaco); break; case 2://1:Quasi-Newton vasp_gui.calc.ibrion=1;break; @@ -1422,7 +1483,8 @@ GUI_UNLOCK(vasp_gui.apaco); /* selecting ISIF */ /******************/ void vasp_isif_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); + gint index; + GUI_COMBOBOX_GET(w,index); vasp_gui.calc.isif=index; switch(index){ case 3://3:F_S_I_S_V @@ -1565,19 +1627,19 @@ void toggle_poscar_direct(){ gdouble ux,uy,uz; gdouble vx,vy,vz; gdouble wx,wy,wz; - /* TODO: recalculate all positions on a single click */ + /**/ GUI_COMBOBOX_GET(vasp_gui.poscar_atoms,index);/*PUSH*/ /*mini sync*/ - VASP_REG_VAL(poscar_a0,"%lf"); - VASP_REG_VAL(poscar_ux,"%lf"); - VASP_REG_VAL(poscar_uy,"%lf"); - VASP_REG_VAL(poscar_uz,"%lf"); - VASP_REG_VAL(poscar_vx,"%lf"); - VASP_REG_VAL(poscar_vy,"%lf"); - VASP_REG_VAL(poscar_vz,"%lf"); - VASP_REG_VAL(poscar_wx,"%lf"); - VASP_REG_VAL(poscar_wy,"%lf"); - VASP_REG_VAL(poscar_wz,"%lf"); + VASP_REG_VAL(poscar_a0,"%lf"); + VASP_REG_VAL(poscar_ux,"%lf"); + VASP_REG_VAL(poscar_uy,"%lf"); + VASP_REG_VAL(poscar_uz,"%lf"); + VASP_REG_VAL(poscar_vx,"%lf"); + VASP_REG_VAL(poscar_vy,"%lf"); + VASP_REG_VAL(poscar_vz,"%lf"); + VASP_REG_VAL(poscar_wx,"%lf"); + VASP_REG_VAL(poscar_wy,"%lf"); + VASP_REG_VAL(poscar_wz,"%lf"); ux=vasp_gui.calc.poscar_ux*vasp_gui.calc.poscar_a0; uy=vasp_gui.calc.poscar_uy*vasp_gui.calc.poscar_a0; uz=vasp_gui.calc.poscar_uz*vasp_gui.calc.poscar_a0; @@ -1590,8 +1652,8 @@ void toggle_poscar_direct(){ /**/ GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); - while(g_ascii_strcasecmp(text,"ADD atom")!=0){ - /*get each line*/ + while(g_ascii_strcasecmp(text,"ADD atom")!=0){ + /*get each line*/ tamp=g_strdup(text);/*to get enough space*/ sscanf(text,"%lf %lf %lf %[^\n]",&x,&y,&z,tamp); g_free(text); @@ -1638,7 +1700,7 @@ void vasp_poscar_atoms_selected(GtkWidget *w, struct model_pak *model){ if (g_ascii_strcasecmp(text,"ADD atom") == 0) { /*allow symbol*/ GUI_UNLOCK(vasp_gui.poscar_symbol); - }else{ + }else{ /*populate atom properties*/ sscanf(text,"%lf %lf %lf %c %c %c ! atom: %*i (%[^)])",&x,&y,&z,&tx,&ty,&tz,&(symbol[0])); g_free(text);text=g_strdup_printf("%s",symbol); @@ -1751,149 +1813,184 @@ void vasp_atom_delete(){ g_free(text); vasp_gui.poscar_dirty=TRUE; } -/* XXX XXX XXX HERE XXX XXX XXX */ /**************************/ /* selecting kpoints_mode */ /**************************/ void vasp_kpoints_mode_selected(GtkWidget *w, struct model_pak *model){ - const gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gtk_widget_set_sensitive(vasp_gui.kpoints_w,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_cart,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_tetra,FALSE); - gtk_widget_set_sensitive(vasp_gui.have_tetra,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_coord,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_kx,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_ky,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_kz,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_sx,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_sy,FALSE); - gtk_widget_set_sensitive(vasp_gui.kpoints_sz,FALSE); + gint index; + gchar *text; + GUI_COMBOBOX_GET(w,index); + GUI_LOCK(vasp_gui.kpoints_w); + GUI_LOCK(vasp_gui.kpoints_cart); + GUI_LOCK(vasp_gui.kpoints_tetra); + GUI_LOCK(vasp_gui.have_tetra); + GUI_LOCK(vasp_gui.kpoints_coord); + GUI_LOCK(vasp_gui.kpoints_kx); + GUI_LOCK(vasp_gui.kpoints_ky); + GUI_LOCK(vasp_gui.kpoints_kz); + GUI_LOCK(vasp_gui.kpoints_sx); + GUI_LOCK(vasp_gui.kpoints_sy); + GUI_LOCK(vasp_gui.kpoints_sz); switch(index){ case 0://Manual Entry vasp_gui.calc.kpoints_mode=VKP_MAN; - gtk_widget_set_sensitive(vasp_gui.kpoints_w,TRUE); - gtk_widget_set_sensitive(vasp_gui.kpoints_coord,TRUE);//need coord - gtk_widget_set_sensitive(vasp_gui.kpoints_nkpts,TRUE);//need nkpts - gtk_widget_set_sensitive(vasp_gui.kpoints_cart,TRUE);//can be cart - if(vasp_gui.calc.ismear==-5) gtk_widget_set_sensitive(vasp_gui.kpoints_tetra,TRUE);//only VKP_MAN require tetra - if(vasp_gui.calc.ismear==-5) gtk_widget_set_sensitive(vasp_gui.have_tetra,TRUE);//and only if ISMEAR=-5 + GUI_UNLOCK(vasp_gui.kpoints_w); + GUI_UNLOCK(vasp_gui.kpoints_coord); + GUI_UNLOCK(vasp_gui.kpoints_nkpts); + GUI_UNLOCK(vasp_gui.kpoints_cart); + if(vasp_gui.calc.ismear==-5) { + GUI_UNLOCK(vasp_gui.kpoints_tetra); + GUI_UNLOCK(vasp_gui.have_tetra); + } break; case 1://Line Mode vasp_gui.calc.kpoints_mode=VKP_LINE; - gtk_widget_set_sensitive(vasp_gui.kpoints_coord,TRUE);//need coord - gtk_widget_set_sensitive(vasp_gui.kpoints_nkpts,TRUE);//need nkpts - gtk_widget_set_sensitive(vasp_gui.kpoints_cart,TRUE);//can be cart + GUI_UNLOCK(vasp_gui.kpoints_coord); + GUI_UNLOCK(vasp_gui.kpoints_nkpts); + GUI_UNLOCK(vasp_gui.kpoints_cart); break; case 3://Gamma (M&P) vasp_gui.calc.kpoints_mode=VKP_GAMMA; - gtk_widget_set_sensitive(vasp_gui.kpoints_kx,TRUE);//require kx - gtk_widget_set_sensitive(vasp_gui.kpoints_ky,TRUE);//require ky - gtk_widget_set_sensitive(vasp_gui.kpoints_kz,TRUE);//require kz - gtk_widget_set_sensitive(vasp_gui.kpoints_sx,TRUE);//require sx - gtk_widget_set_sensitive(vasp_gui.kpoints_sy,TRUE);//require sy - gtk_widget_set_sensitive(vasp_gui.kpoints_sz,TRUE);//require sz + GUI_UNLOCK(vasp_gui.kpoints_kx); + GUI_UNLOCK(vasp_gui.kpoints_ky); + GUI_UNLOCK(vasp_gui.kpoints_kz); + GUI_UNLOCK(vasp_gui.kpoints_sx); + GUI_UNLOCK(vasp_gui.kpoints_sy); + GUI_UNLOCK(vasp_gui.kpoints_sz); vasp_gui.calc.kpoints_nkpts=0; - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_nkpts),g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts)); - gtk_widget_set_sensitive(vasp_gui.kpoints_nkpts,FALSE);//NKPTS is 0 and disable + text=g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts); + GUI_ENTRY_TEXT(vasp_gui.kpoints_nkpts,text); + g_free(text); + GUI_LOCK(vasp_gui.kpoints_nkpts); break; case 4://Monkhorst-Pack classic vasp_gui.calc.kpoints_mode=VKP_MP; - gtk_widget_set_sensitive(vasp_gui.kpoints_kx,TRUE);//require kx - gtk_widget_set_sensitive(vasp_gui.kpoints_ky,TRUE);//require ky - gtk_widget_set_sensitive(vasp_gui.kpoints_kz,TRUE);//require kz - gtk_widget_set_sensitive(vasp_gui.kpoints_sx,TRUE);//require sx - gtk_widget_set_sensitive(vasp_gui.kpoints_sy,TRUE);//require sy - gtk_widget_set_sensitive(vasp_gui.kpoints_sz,TRUE);//require sz + GUI_UNLOCK(vasp_gui.kpoints_kx); + GUI_UNLOCK(vasp_gui.kpoints_ky); + GUI_UNLOCK(vasp_gui.kpoints_kz); + GUI_UNLOCK(vasp_gui.kpoints_sx); + GUI_UNLOCK(vasp_gui.kpoints_sy); + GUI_UNLOCK(vasp_gui.kpoints_sz); vasp_gui.calc.kpoints_nkpts=0; - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_nkpts),g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts)); - gtk_widget_set_sensitive(vasp_gui.kpoints_nkpts,FALSE);//NKPTS is 0 and disable + text=g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts); + GUI_ENTRY_TEXT(vasp_gui.kpoints_nkpts,text); + g_free(text); + GUI_LOCK(vasp_gui.kpoints_nkpts); break; case 5://Basis set definition vasp_gui.calc.kpoints_mode=VKP_BASIS; - gtk_widget_set_sensitive(vasp_gui.kpoints_coord,TRUE);//need coord - gtk_widget_set_sensitive(vasp_gui.kpoints_nkpts,TRUE);//need nkpts - gtk_widget_set_sensitive(vasp_gui.kpoints_cart,TRUE);//can be cart + GUI_UNLOCK(vasp_gui.kpoints_coord); + GUI_UNLOCK(vasp_gui.kpoints_nkpts); + GUI_UNLOCK(vasp_gui.kpoints_cart); break; case 2://Automatic (M&P) default: vasp_gui.calc.kpoints_mode=VKP_AUTO; - gtk_widget_set_sensitive(vasp_gui.kpoints_kx,TRUE);//AUTO only require kx + GUI_UNLOCK(vasp_gui.kpoints_kx); vasp_gui.calc.kpoints_nkpts=0; - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_nkpts),g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts)); - gtk_widget_set_sensitive(vasp_gui.kpoints_nkpts,FALSE);//NKPTS is 0 and disable + text=g_strdup_printf("%i",vasp_gui.calc.kpoints_nkpts); + GUI_ENTRY_TEXT(vasp_gui.kpoints_nkpts,text); + g_free(text); + GUI_LOCK(vasp_gui.kpoints_nkpts); } } /**********************/ /* selecting a kpoint */ /**********************/ void vasp_kpoints_kpts_selected(GtkWidget *w, struct model_pak *model){ - /* using combobox*/ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(w)); - gdouble x,y,z,wt; - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_i),g_strdup_printf("%i",index+1)); + gint index; + gchar *text; + gdouble x,y,z,wt; + /**/ + GUI_COMBOBOX_GET(w,index); + text=g_strdup_printf("%i",index+1); + GUI_ENTRY_TEXT(vasp_gui.kpoints_i,text); + g_free(text); + GUI_COMBOBOX_GET_TEXT(w,text); if (g_ascii_strcasecmp(text,"ADD kpoint") == 0) { - /*no need to update anything but index*/ + /*no need to update anything but index*/ } else { /*update index,x,y,z,w*/ wt=0.0; if(vasp_gui.calc.kpoints_mode==VKP_LINE) sscanf(text,"%lf %lf %lf ! kpoint: %*i",&x,&y,&z); else sscanf(text,"%lf %lf %lf %lf ! kpoint: %*i",&x,&y,&z,&wt); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_x),g_strdup_printf("%.8lf",x)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_y),g_strdup_printf("%.8lf",y)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_z),g_strdup_printf("%.8lf",z)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kpoints_w),g_strdup_printf("%.8lf",wt)); + g_free(text);text=g_strdup_printf("%.8lf",x); + GUI_ENTRY_TEXT(vasp_gui.kpoints_x,text); + g_free(text);text=g_strdup_printf("%.8lf",y); + GUI_ENTRY_TEXT(vasp_gui.kpoints_y,text); + g_free(text);text=g_strdup_printf("%.8lf",z); + GUI_ENTRY_TEXT(vasp_gui.kpoints_z,text); + g_free(text);text=g_strdup_printf("%.8lf",wt); + GUI_ENTRY_TEXT(vasp_gui.kpoints_w,text); } + g_free(text); } /*********************/ /* Add/modify kpoint */ /*********************/ void vasp_kpoint_modified(){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.kpoints_kpts)); - gchar *tamp; - /*mini-sync*/ - VASP_REG_VAL(kpoints_i,"%i"); - VASP_REG_VAL(kpoints_x,"%lf"); - VASP_REG_VAL(kpoints_y,"%lf"); - VASP_REG_VAL(kpoints_z,"%lf"); + gint index; + gchar *text; + gchar *tamp; + /*mini-sync*/ + GUI_COMBOBOX_GET(vasp_gui.kpoints_kpts,index);/*PUSH*/ + GUI_COMBOBOX_GET_TEXT(vasp_gui.kpoints_kpts,text); + VASP_REG_VAL(kpoints_i,"%i"); + VASP_REG_VAL(kpoints_x,"%lf"); + VASP_REG_VAL(kpoints_y,"%lf"); + VASP_REG_VAL(kpoints_z,"%lf"); VASP_REG_VAL(kpoints_w,"%lf"); - /* add/modify */ - if(g_ascii_strcasecmp(text,"ADD kpoint") == 0){ - /*we are going to insert some data*/ - if(vasp_gui.calc.kpoints_mode==VKP_LINE) - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index, - g_strdup_printf("%.8lf %.8lf %.8lf ! kpoint: %i", - vasp_gui.calc.kpoints_x,vasp_gui.calc.kpoints_y,vasp_gui.calc.kpoints_z,index+1)); - else - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index, - g_strdup_printf("%.8lf %.8lf %.8lf %.8lf ! kpoint: %i", - vasp_gui.calc.kpoints_x,vasp_gui.calc.kpoints_y,vasp_gui.calc.kpoints_z,vasp_gui.calc.kpoints_w,index+1)); - }else{ - /*we are goign to modify some data*/ - if(vasp_gui.calc.kpoints_mode==VKP_LINE) - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index, - g_strdup_printf("%.8lf %.8lf %.8lf ! kpoint: %i", - vasp_gui.calc.kpoints_x,vasp_gui.calc.kpoints_y,vasp_gui.calc.kpoints_z,index+1)); - else - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index, - g_strdup_printf("%.8lf %.8lf %.8lf %.8lf ! kpoint: %i", - vasp_gui.calc.kpoints_x,vasp_gui.calc.kpoints_y,vasp_gui.calc.kpoints_z,vasp_gui.calc.kpoints_w,index+1)); - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.kpoints_kpts),index+1); - } - /*re-select current entry (to refresh content)*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index); + /* add/modify */ + if(g_ascii_strcasecmp(text,"ADD kpoint") == 0){ + g_free(text); + /*we are going to insert some data*/ + if(vasp_gui.calc.kpoints_mode==VKP_LINE){ + text=g_strdup_printf("%.8lf %.8lf %.8lf ! kpoint: %i", + vasp_gui.calc.kpoints_x,vasp_gui.calc.kpoints_y,vasp_gui.calc.kpoints_z,index+1); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.kpoints_kpts,index,text); + g_free(text); + }else{ + text=g_strdup_printf("%.8lf %.8lf %.8lf %.8lf ! kpoint: %i", + vasp_gui.calc.kpoints_x,vasp_gui.calc.kpoints_y,vasp_gui.calc.kpoints_z,vasp_gui.calc.kpoints_w,index+1); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.kpoints_kpts,index,text); + g_free(text); + } + }else{ + g_free(text); + /*we are goign to modify some data*/ + if(vasp_gui.calc.kpoints_mode==VKP_LINE){ + text=g_strdup_printf("%.8lf %.8lf %.8lf ! kpoint: %i", + vasp_gui.calc.kpoints_x,vasp_gui.calc.kpoints_y,vasp_gui.calc.kpoints_z,index+1); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.kpoints_kpts,index,text); + g_free(text); + }else{ + text=g_strdup_printf("%.8lf %.8lf %.8lf %.8lf ! kpoint: %i", + vasp_gui.calc.kpoints_x,vasp_gui.calc.kpoints_y,vasp_gui.calc.kpoints_z,vasp_gui.calc.kpoints_w,index+1); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.kpoints_kpts,index,text); + g_free(text); + } + GUI_COMBOBOX_DEL(vasp_gui.kpoints_kpts,index+1); + + } + /*re-select current entry (to refresh content)*/ + GUI_COMBOBOX_SET(vasp_gui.kpoints_kpts,index);/*PULL*/ } /******************/ /* deleted kpoint */ /******************/ void vasp_kpoint_delete(){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.kpoints_kpts)); - if(g_ascii_strcasecmp(text,"ADD kpoint") == 0) return;/*can't delete this one*/ - if(index==-1) return;/*nothing selected anyway*/ - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.kpoints_kpts),index); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index-1); + gint index; + gchar *text; + GUI_COMBOBOX_GET(vasp_gui.kpoints_kpts,index); + if(index==-1) return;/*nothing selected anyway*/ + GUI_COMBOBOX_GET_TEXT(vasp_gui.kpoints_kpts,text); + if(g_ascii_strcasecmp(text,"ADD kpoint") == 0) { + g_free(text); + return;/*can't delete this one*/ + } + g_free(text); + GUI_COMBOBOX_DEL(vasp_gui.kpoints_kpts,index); + GUI_COMBOBOX_SET(vasp_gui.kpoints_kpts,index-1); } /****************/ /* tetra toggle */ @@ -1902,71 +1999,94 @@ void toogle_tetra(){ /*enable/disable tetrahedron*/ if(vasp_gui.calc.ismear!=-5) vasp_gui.calc.kpoints_tetra=FALSE;/*ISMEAR=-5 required*/ if(vasp_gui.calc.kpoints_mode!=VKP_MAN) vasp_gui.calc.kpoints_tetra=FALSE;/*manual generation must be selected*/ - if(vasp_gui.calc.kpoints_tetra==FALSE) gtk_widget_set_sensitive(vasp_gui.kpoints_tetra,FALSE); - else gtk_widget_set_sensitive(vasp_gui.kpoints_tetra,TRUE); + if(vasp_gui.calc.kpoints_tetra==FALSE) GUI_LOCK(vasp_gui.kpoints_tetra); + else GUI_UNLOCK(vasp_gui.kpoints_tetra); } /*************************/ /* selecting tetrahedron */ /*************************/ void vasp_tetra_selected(GtkWidget *w, struct model_pak *model){ - /* using combobox*/ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(w)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(w)); + gint index; + gchar *text; gdouble wt; gint a,b,c,d; + /**/ + GUI_COMBOBOX_GET(w,index); + GUI_COMBOBOX_GET_TEXT(w,text); if (g_ascii_strcasecmp(text,"ADD tetrahedron") == 0) { /*no need to update anything*/ } else { sscanf(text,"%lf %i %i %i %i ! tetrahedron: %*i",&wt,&a,&b,&c,&d); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.tetra_i),g_strdup_printf("%i",index)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.tetra_w),g_strdup_printf("%.4lf",wt)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.tetra_a),g_strdup_printf("%i",a)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.tetra_b),g_strdup_printf("%i",b)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.tetra_c),g_strdup_printf("%i",c)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.tetra_d),g_strdup_printf("%i",d)); + g_free(text);text=g_strdup_printf("%i",index); + GUI_ENTRY_TEXT(vasp_gui.tetra_i,text); + g_free(text);text=g_strdup_printf("%.4lf",wt); + GUI_ENTRY_TEXT(vasp_gui.tetra_w,text); + g_free(text);text=g_strdup_printf("%i",a); + GUI_ENTRY_TEXT(vasp_gui.tetra_a,text); + g_free(text);text=g_strdup_printf("%i",b); + GUI_ENTRY_TEXT(vasp_gui.tetra_b,text); + g_free(text);text=g_strdup_printf("%i",c); + GUI_ENTRY_TEXT(vasp_gui.tetra_c,text); + g_free(text);text=g_strdup_printf("%i",d); + GUI_ENTRY_TEXT(vasp_gui.tetra_d,text); } + g_free(text); } /**************************/ /* Add/modify tetrahedron */ /**************************/ void vasp_tetra_modified(){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.tetra)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.tetra)); - gchar *tamp; - - /*mini-sync*/ - VASP_REG_VAL(tetra_i,"%i"); - VASP_REG_VAL(tetra_w,"%lf"); + gint index; + gchar *text; + gchar *tamp; + /*mini-sync*/ + GUI_COMBOBOX_GET(vasp_gui.tetra,index); + GUI_COMBOBOX_GET_TEXT(vasp_gui.tetra,text); + VASP_REG_VAL(tetra_i,"%i"); + VASP_REG_VAL(tetra_w,"%lf"); VASP_REG_VAL(tetra_a,"%i"); - VASP_REG_VAL(tetra_b,"%i"); - VASP_REG_VAL(tetra_c,"%i"); - VASP_REG_VAL(tetra_d,"%i"); - /* add/modify */ - if(g_ascii_strcasecmp(text,"ADD tetrahedron") == 0){ - /*we are going to insert some data*/ - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.tetra),index, - g_strdup_printf("%lf %i %i %i %i ! tetrahedron: %i", - vasp_gui.calc.tetra_w,vasp_gui.calc.tetra_a,vasp_gui.calc.tetra_b,vasp_gui.calc.tetra_c,vasp_gui.calc.tetra_d,index)); - }else{ - /*we are goign to modify some data*/ - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.tetra),index, - g_strdup_printf("%lf %i %i %i %i ! tetrahedron: %i", - vasp_gui.calc.tetra_w,vasp_gui.calc.tetra_a,vasp_gui.calc.tetra_b,vasp_gui.calc.tetra_c,vasp_gui.calc.tetra_d,index)); - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.tetra),index+1); - } - /*re-select current entry (to refresh content)*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.tetra),index); + VASP_REG_VAL(tetra_b,"%i"); + VASP_REG_VAL(tetra_c,"%i"); + VASP_REG_VAL(tetra_d,"%i"); + /* add/modify */ + if(g_ascii_strcasecmp(text,"ADD tetrahedron") == 0){ + /*we are going to insert some data*/ + g_free(text); + text=g_strdup_printf("%lf %i %i %i %i ! tetrahedron: %i", + vasp_gui.calc.tetra_w,vasp_gui.calc.tetra_a,vasp_gui.calc.tetra_b,vasp_gui.calc.tetra_c,vasp_gui.calc.tetra_d,index); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.tetra,index,text); + }else{ + /*we are goign to modify some data*/ + g_free(text); + text=g_strdup_printf("%lf %i %i %i %i ! tetrahedron: %i", + vasp_gui.calc.tetra_w,vasp_gui.calc.tetra_a,vasp_gui.calc.tetra_b,vasp_gui.calc.tetra_c,vasp_gui.calc.tetra_d,index); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.tetra,index,text); + GUI_COMBOBOX_DEL(vasp_gui.tetra,index+1); + } + g_free(text); + /*re-select current entry (to refresh content)*/ + GUI_COMBOBOX_SET(vasp_gui.tetra,index); } /**********************/ /* delete tetrahedron */ /**********************/ void vasp_tetra_delete(){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.tetra)); - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.tetra)); - if(g_ascii_strcasecmp(text,"ADD tetrahedron") == 0) return;/*can't delete this one*/ - if(index==-1) return;/*nothing selected anyway*/ - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.tetra),index); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.tetra),index-1); + gint index; + gchar *text; + GUI_COMBOBOX_GET(vasp_gui.tetra,index); + if(index==-1) {/*TODO: set similar strategy to kpoints and atom lists*/ + GUI_COMBOBOX_SET(vasp_gui.tetra,0); + return;/*nothing selected anyway*/ + } + GUI_COMBOBOX_GET_TEXT(vasp_gui.tetra,text); + if(g_ascii_strcasecmp(text,"ADD tetrahedron") == 0) { + g_free(text); + return;/*can't delete this one*/ + } + g_free(text); + GUI_COMBOBOX_DEL(vasp_gui.tetra,index); + if(index-1<0) index=1;/*TODO: set similar strategy to kpoints and atom lists*/ + GUI_COMBOBOX_SET(vasp_gui.tetra,index-1); } /****************************************************/ /* get species information (ie. symbol) from POTCAR */ @@ -1978,11 +2098,11 @@ void potcar_get_species(){ gchar sym[3]; /*the resulting species information should match that of POSCAR*/ fp=fopen(vasp_gui.calc.potcar_file,"r"); - if (!fp) { + if (!fp) { if(vasp_gui.calc.potcar_species!=NULL) g_free(vasp_gui.calc.potcar_species); vasp_gui.calc.potcar_species=NULL; - return; - } + return; + } /*file is opened*/ sym[2]='\0'; if(vasp_gui.calc.potcar_species!=NULL) g_free(vasp_gui.calc.potcar_species); @@ -2027,11 +2147,11 @@ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filt filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); if(filename) { gtk_entry_set_text(GTK_ENTRY(vasp_gui.simple_potcar),g_strdup_printf("%s",filename)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_file),g_strdup_printf("%s",filename)); + gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_file),g_strdup_printf("%s",filename)); /*dont forget to sync!!*/ - VASP_REG_TEXT(potcar_file); - g_free (filename); - potcar_get_species(); + VASP_REG_TEXT(potcar_file); + g_free (filename); + potcar_get_species(); } } gtk_widget_destroy (GTK_WIDGET(file_chooser)); @@ -2161,8 +2281,8 @@ void potcar_folder_get_info(){ } vasp_gui.calc.potcar_species=g_strdup(vasp_gui.calc.species_symbols);/*just copy is enough for now*/ vasp_gui.calc.potcar_species_flavor=g_strdup(vasp_gui.calc.species_symbols);/*same here*/ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.simple_species),g_strdup_printf("%s",vasp_gui.calc.potcar_species)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_species),g_strdup_printf("%s",vasp_gui.calc.potcar_species)); + gtk_entry_set_text(GTK_ENTRY(vasp_gui.simple_species),g_strdup_printf("%s",vasp_gui.calc.potcar_species)); + gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_species),g_strdup_printf("%s",vasp_gui.calc.potcar_species)); gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_species_flavor),g_strdup_printf("%s",vasp_gui.calc.potcar_species_flavor)); gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.species_flavor),0); } @@ -2177,10 +2297,10 @@ file_chooser=gtk_file_chooser_dialog_new("Select the POTCAR folder",GTK_WINDOW(v { char *foldername = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); if(foldername) { - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_folder),g_strdup_printf("%s",foldername)); + gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_folder),g_strdup_printf("%s",foldername)); if(vasp_gui.calc.potcar_folder!=NULL) g_free(vasp_gui.calc.potcar_folder); vasp_gui.calc.potcar_folder=g_strdup_printf("%s",foldername); - g_free (foldername); + g_free (foldername); potcar_folder_get_info(); } } @@ -2248,92 +2368,92 @@ void parallel_eq(GtkWidget *w, GtkWidget *box){ /* sync poscar information */ /***************************/ void vasp_poscar_sync(){ - gchar *tamp; - gchar *text; - gchar *text2; - gchar *tamp2; - gchar symbol[3]; - gint idx,jdx; + gchar *tamp; + gchar *text; + gchar *text2; + gchar *tamp2; + gchar symbol[3]; + gint idx,jdx; if(vasp_gui.poscar_dirty==FALSE) return;/*ne need to update*/ /* pass_1: GROUP atom list by atom types */ - idx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - while(g_ascii_strcasecmp(text,"ADD atom")!=0){ - sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); - jdx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),jdx); - text2=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - while(g_ascii_strcasecmp(text2,"ADD atom")!=0){ - /**/ - sscanf(text2,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(symbol[0])); - if(g_ascii_strcasecmp(vasp_gui.calc.poscar_symbol,symbol) == 0){ - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),jdx); - gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),text2); - idx++; - } - jdx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),jdx); - text2=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - } - idx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - } + idx=0; + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); + text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + while(g_ascii_strcasecmp(text,"ADD atom")!=0){ + sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); + jdx=0; + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),jdx); + text2=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + while(g_ascii_strcasecmp(text2,"ADD atom")!=0){ + /**/ + sscanf(text2,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(symbol[0])); + if(g_ascii_strcasecmp(vasp_gui.calc.poscar_symbol,symbol) == 0){ + gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),jdx); + gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),text2); + idx++; + } + jdx++; + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),jdx); + text2=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + } + idx++; + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); + text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + } /* pass_2: REORDER atom list <- useful for 'consistent' ordering*/ - idx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - while(g_ascii_strcasecmp(text,"ADD atom")!=0){ - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),idx); - gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),text); - idx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - } + idx=0; + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); + text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + while(g_ascii_strcasecmp(text,"ADD atom")!=0){ + gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),idx); + gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),text); + idx++; + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); + text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + } /* pass_3: SETUP unexposed properties (fix atom index)*/ - idx=0;jdx=0;vasp_gui.calc.electron_total=0; - vasp_gui.calc.species_total=1; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); - tamp=g_strdup_printf(" %s",vasp_gui.calc.poscar_symbol); - tamp2=g_strdup_printf(" "); - while(g_ascii_strcasecmp(text,"ADD atom")!=0){ - /*get each line*/ - sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(symbol[0])); + idx=0;jdx=0;vasp_gui.calc.electron_total=0; + vasp_gui.calc.species_total=1; + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); + text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); + tamp=g_strdup_printf(" %s",vasp_gui.calc.poscar_symbol); + tamp2=g_strdup_printf(" "); + while(g_ascii_strcasecmp(text,"ADD atom")!=0){ + /*get each line*/ + sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(symbol[0])); text2=g_strdup(text);/*to get enough space*/ sscanf(text,"%[^!]%*s",text2); - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx,g_strdup_printf("%s! atom: %i (%s)",text2,idx,symbol)); - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),idx+1); + gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx,g_strdup_printf("%s! atom: %i (%s)",text2,idx,symbol)); + gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),idx+1); g_free(text2); vasp_gui.calc.electron_total+=elem_symbol_test(symbol); - if(g_ascii_strcasecmp(vasp_gui.calc.poscar_symbol,symbol) != 0) { - /*new species*/ - text=g_strdup_printf("%s %s",tamp,symbol); - g_free(tamp); - tamp=text; - text=g_strdup_printf("%s %i",tamp2,jdx); - g_free(tamp2); - tamp2=text; - vasp_gui.calc.species_total++; - sprintf(vasp_gui.calc.poscar_symbol,"%s",symbol); - jdx=0; - } - idx++; - jdx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - } - vasp_gui.calc.atoms_total=idx;/*so we have the total number of atoms*/ - /*we need to get the last jdx*/ - text=g_strdup_printf("%s %i",tamp2,jdx); - g_free(tamp2); - tamp2=text; - if(vasp_gui.calc.species_symbols!=NULL) g_free(vasp_gui.calc.species_symbols); - if(vasp_gui.calc.species_numbers!=NULL) g_free(vasp_gui.calc.species_numbers); - vasp_gui.calc.species_symbols=g_strdup(tamp);g_free(tamp); - vasp_gui.calc.species_numbers=g_strdup(tamp2);g_free(tamp2); + if(g_ascii_strcasecmp(vasp_gui.calc.poscar_symbol,symbol) != 0) { + /*new species*/ + text=g_strdup_printf("%s %s",tamp,symbol); + g_free(tamp); + tamp=text; + text=g_strdup_printf("%s %i",tamp2,jdx); + g_free(tamp2); + tamp2=text; + vasp_gui.calc.species_total++; + sprintf(vasp_gui.calc.poscar_symbol,"%s",symbol); + jdx=0; + } + idx++; + jdx++; + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); + text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + } + vasp_gui.calc.atoms_total=idx;/*so we have the total number of atoms*/ + /*we need to get the last jdx*/ + text=g_strdup_printf("%s %i",tamp2,jdx); + g_free(tamp2); + tamp2=text; + if(vasp_gui.calc.species_symbols!=NULL) g_free(vasp_gui.calc.species_symbols); + if(vasp_gui.calc.species_numbers!=NULL) g_free(vasp_gui.calc.species_numbers); + vasp_gui.calc.species_symbols=g_strdup(tamp);g_free(tamp); + vasp_gui.calc.species_numbers=g_strdup(tamp2);g_free(tamp2); vasp_gui.poscar_dirty=FALSE; } @@ -2341,7 +2461,7 @@ void vasp_poscar_sync(){ /* Switch notebook page */ /************************/ void vasp_gui_page_switch(GtkNotebook *notebook,GtkWidget *page,guint page_num,gpointer user_data){ - /* some (few) values need to be updated from a page to another*/ + /* some (few) values need to be updated from a page to another*/ vasp_gui.cur_page=page_num;/*TODO: for (adv.)*/ if(page_num==VASP_PAGE_SIMPLIFIED){ vasp_poscar_sync();/*we need to know species_symbols*/ @@ -2360,9 +2480,9 @@ void vasp_gui_page_switch(GtkNotebook *notebook,GtkWidget *page,guint page_num,g gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.kgamma_3),vasp_gui.calc.kgamma); gtk_entry_set_text(GTK_ENTRY(vasp_gui.kspacing_3),g_strdup_printf("%.4lf",vasp_gui.calc.kspacing)); gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_mode),vasp_gui.calc.kpoints_mode); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kx),vasp_gui.calc.kpoints_kx); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_ky),vasp_gui.calc.kpoints_ky); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kz),vasp_gui.calc.kpoints_kz); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kx),vasp_gui.calc.kpoints_kx); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_ky),vasp_gui.calc.kpoints_ky); + gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kz),vasp_gui.calc.kpoints_kz); toogle_tetra();/*in case we need*/ } else if (page_num==VASP_PAGE_POTCAR){ vasp_poscar_sync();/*we need to know species_symbols*/ @@ -2408,7 +2528,7 @@ void vasp_gui_sync(){ VASP_REG_VAL(lmaxpaw,"%i"); VASP_REG_VAL(istart,"%i"); VASP_REG_VAL(icharg,"%i"); - //iniwav already sync + //iniwav already sync //ispin already sync //non_collinear already sync VASP_REG_TEXT(magmom); @@ -2503,18 +2623,18 @@ void vasp_gui_sync(){ vasp_poscar_sync(); /*no need to sync individual poscar entry*/ /*PROCESS KPOINTS*/ - VASP_REG_VAL(kpoints_nkpts,"%i"); + VASP_REG_VAL(kpoints_nkpts,"%i"); VASP_REG_VAL(kpoints_kx,"%lf"); VASP_REG_VAL(kpoints_ky,"%lf"); VASP_REG_VAL(kpoints_kz,"%lf"); VASP_REG_VAL(kpoints_sx,"%lf"); VASP_REG_VAL(kpoints_sy,"%lf"); VASP_REG_VAL(kpoints_sz,"%lf"); - VASP_REG_VAL(kpoints_i,"%i"); - VASP_REG_VAL(kpoints_x,"%lf"); - VASP_REG_VAL(kpoints_y,"%lf"); - VASP_REG_VAL(kpoints_z,"%lf"); - VASP_REG_VAL(kpoints_w,"%lf"); + VASP_REG_VAL(kpoints_i,"%i"); + VASP_REG_VAL(kpoints_x,"%lf"); + VASP_REG_VAL(kpoints_y,"%lf"); + VASP_REG_VAL(kpoints_z,"%lf"); + VASP_REG_VAL(kpoints_w,"%lf"); VASP_REG_VAL(tetra_total,"%i"); VASP_REG_VAL(tetra_volume,"%lf"); /*no need to sync individual tetrahedron entry*/ @@ -2533,7 +2653,7 @@ void calc_to_poscar(FILE *output,vasp_calc_struct calc){ gchar tx,ty,tz; gint idx; /* generate a VASP5 POSCAR file */ - if(calc.name!=NULL) fprintf(output,"%s ",calc.name); + if(calc.name!=NULL) fprintf(output,"%s ",calc.name); else fprintf(output,"UNNAMED MODEL "); fprintf(output,"! GENERATED BY GDIS %4.2f.%d (C) %d\n",VERSION,PATCH,YEAR); fprintf(output,"%lf\n",calc.poscar_a0); @@ -2548,17 +2668,17 @@ void calc_to_poscar(FILE *output,vasp_calc_struct calc){ if(calc.poscar_direct) fprintf(output,"Direct\n"); else fprintf(output,"Cartesian\n"); idx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); + text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); - while(g_ascii_strcasecmp(text,"ADD atom")!=0){ + while(g_ascii_strcasecmp(text,"ADD atom")!=0){ /*get each line*/ sscanf(text,"%lf %lf %lf %c %c %c %*s",&x,&y,&z,&tx,&ty,&tz); fprintf(output," % .8lf % .8lf % .8lf %c %c %c\n",x,y,z,tx,ty,tz); idx++; gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - } + } gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),index); } /****************************************************/ @@ -2582,32 +2702,32 @@ void calc_to_kpoints(FILE *output,vasp_calc_struct calc){ case VKP_LINE: fprintf(output,"Line-mode\n"); case VKP_BASIS: - case VKP_MAN: + case VKP_MAN: if(vasp_gui.calc.kpoints_cart) fprintf(output,"Cartesian\n"); else fprintf(output,"Reciprocal\n"); break; - case VKP_GAMMA: + case VKP_GAMMA: fprintf(output,"Gamma\n"); fprintf(output,"%i %i %i\n",(gint)vasp_gui.calc.kpoints_kx,(gint)vasp_gui.calc.kpoints_ky,(gint)vasp_gui.calc.kpoints_kz); if((vasp_gui.calc.kpoints_sx!=0.0)&&(vasp_gui.calc.kpoints_sy!=0.0)&&(vasp_gui.calc.kpoints_sz!=0.0)) fprintf(output,"%lf %lf %lf\n",vasp_gui.calc.kpoints_sx,vasp_gui.calc.kpoints_sy,vasp_gui.calc.kpoints_sz); return; - case VKP_MP: + case VKP_MP: fprintf(output,"Monkhorst-Pack\n"); fprintf(output,"%i %i %i\n",(gint)vasp_gui.calc.kpoints_kx,(gint)vasp_gui.calc.kpoints_ky,(gint)vasp_gui.calc.kpoints_kz); if((vasp_gui.calc.kpoints_sx!=0.0)&&(vasp_gui.calc.kpoints_sy!=0.0)&&(vasp_gui.calc.kpoints_sz!=0.0)) fprintf(output,"%lf %lf %lf\n",vasp_gui.calc.kpoints_sx,vasp_gui.calc.kpoints_sy,vasp_gui.calc.kpoints_sz); return; - case VKP_AUTO: + case VKP_AUTO: fprintf(output,"Auto\n"); fprintf(output,"%i\n",(gint)vasp_gui.calc.kpoints_kx); return; - } + } /*print all coordinates*/ idx=0; gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),idx); text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.kpoints_kpts)); - while(g_ascii_strcasecmp(text,"ADD kpoint")!=0){ + while(g_ascii_strcasecmp(text,"ADD kpoint")!=0){ if(vasp_gui.calc.kpoints_mode==VKP_MAN) { sscanf(text,"%lf %lf %lf %lf ! kpoint: %*i",&x,&y,&z,&wt); fprintf(output,"%lf %lf %lf %lf ! kpoint: %i\n",x,y,z,wt,idx+1); @@ -2620,7 +2740,7 @@ void calc_to_kpoints(FILE *output,vasp_calc_struct calc){ text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.kpoints_kpts)); } /*return to previous postition*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index); + gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index); /*print all tetrahedron (if any)*/ if(!vasp_gui.calc.kpoints_tetra) return; fprintf(output,"Tetrahedron\n"); @@ -2791,8 +2911,8 @@ void run_vasp_exec(vasp_exec_struct *vasp_exec,struct task_pak *task){ #if __WIN32 /* At present running vasp in __WIN32 environment is impossible. - * However, it should be possible to launch a (remote) job on a - * distant server. See TODO */ + * However, it should be possible to launch a (remote) job on a + * distant server. See TODO */ fprintf(stderr,"VASP calculation can't be done in this environment.\n");return; #else /*direct launch*/ @@ -2818,7 +2938,7 @@ void cleanup_vasp_exec(vasp_exec_struct *vasp_exec){ while(!(*vasp_exec).have_result) usleep(500*1000);/*sleep 500ms until job is done*/ /*init a model*/ result_model=model_new(); - model_init(result_model); + model_init(result_model); /*put result into it*/ filename=g_strdup_printf("%s/vasprun.xml",(*vasp_exec).job_path); /*TODO: detect if a calculation have failed*/ @@ -3212,6 +3332,9 @@ GUI_TOOLTIP(vasp_gui.kspacing,"KSPACING: Ch. 6.4 DEFAULT: 0.5\nWhen KPOINTS file GUI_TOOLTIP(vasp_gui.fermwe,"FERMWE: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 explicitly sets\noccupancy for each band."); GUI_TEXT_TABLE(table,vasp_gui.fermdo,vasp_gui.calc.fermdo,"FERMDO=",2,4,1,2); GUI_TOOLTIP(vasp_gui.fermdo,"FERDO: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 and ISPIN=2 sets\noccupancy for down spin of each band."); +/* initialize */ + GUI_ENTRY_CHANGE(vasp_gui.ismear,ismear_changed,data);/*NEW: ELECT-I ismear -> KPOINTS ismear*/ + GUI_ENTRY_CHANGE(vasp_gui.kspacing,kspacing_changed,data);/*NEW: ELECT-I kspacing -> KPOINTS kspacing*/ /* --- end frame */ /* --- spin */ GUI_FRAME_NOTE(page,frame,"Spin"); @@ -3326,7 +3449,7 @@ GUI_TOOLTIP(vasp_gui.dipol,"DIPOL: Ch. 6.64 DEFAULT: -\nSets the center of the n GUI_ENTRY_TABLE(table,vasp_gui.epsilon,vasp_gui.calc.epsilon,"%.4lf","EPSILON=",3,4,2,3); GUI_TOOLTIP(vasp_gui.epsilon,"EPSILON: Ch. 6.64 DEFAULT: 1\nSets the dielectric constant of the medium."); GUI_ENTRY_TABLE(table,vasp_gui.efield,vasp_gui.calc.efield,"%.4lf","EFIELD=",4,5,2,3); -GUI_TOOLTIP(vasp_gui.efield,"EFIELD: Ch. 6.64 DEFAULT: 0\nApply an external electrostatic field\nin a slab, or molecule calculation.\nOnly a single component can be given\nparallel to IDIPOL direction (1-3)."); +GUI_TOOLTIP(vasp_gui.efield,"EFIELD: Ch. 6.64 DEFAULT: 0\nApply an external electrostatic field\nin a slab, or molecule calculation.\nOnly a single component can be given\nparallel to IDIPOL direction (1-3)."); /*initialize sensitive widget*/ GUI_COMBOBOX_SETUP(vasp_gui.idipol,0,vasp_idipol_selected); if(vasp_gui.calc.idipol!=VID_0) { @@ -3562,17 +3685,17 @@ GUI_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin third latt sym[2]='\0'; if(vasp_gui.calc.poscar_free==VPF_FIXED){ GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms, - g_strdup_printf("%.8lf %.8lf %.8lf F F F ! atom: %i (%s)",core->x[0],core->x[1],core->x[2],idx,sym)); + g_strdup_printf("%.8lf %.8lf %.8lf F F F ! atom: %i (%s)",core->x[0],core->x[1],core->x[2],idx,sym)); }else{ GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms, - g_strdup_printf("%.8lf %.8lf %.8lf T T T ! atom: %i (%s)",core->x[0],core->x[1],core->x[2],idx,sym)); + g_strdup_printf("%.8lf %.8lf %.8lf T T T ! atom: %i (%s)",core->x[0],core->x[1],core->x[2],idx,sym)); } idx++; } vasp_gui.calc.atoms_total=idx; GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms,"ADD atom"); GUI_COMBOBOX_SETUP(vasp_gui.poscar_atoms,idx,vasp_poscar_atoms_selected); - /*this combo is special and should be explicitely defined*/ + /*this combo is special and should be explicitely defined*/ GUI_TOOLTIP(vasp_gui.poscar_atoms,"Atoms positions in POSCAR format."); /*2 buttons*/ GUI_2BUTTONS_TABLE(table,vasp_atom_modified,vasp_atom_delete,4,5,5,6); @@ -3668,7 +3791,7 @@ GUI_TOOLTIP(vasp_gui.kpoints_sz,"In case a grid is used to generate k-points\nTh GUI_COMBOBOX_TABLE(table,vasp_gui.kpoints_kpts,"KPOINT:",0,4,0,1); GUI_COMBOBOX_ADD(vasp_gui.kpoints_kpts,"ADD kpoint"); GUI_TOOLTIP(vasp_gui.kpoints_kpts,"List of the k-points coordinates.\nThe index after comment sign \"! kpoint:\" can be used\nfor entering tetrahedron edge definition."); - /*2 buttons*/ + /*2 buttons*/ GUI_2BUTTONS_TABLE(table,vasp_kpoint_modified,vasp_kpoint_delete,4,5,0,1); /* 2nd line */ GUI_ENTRY_TABLE(table,vasp_gui.kpoints_i,vasp_gui.calc.kpoints_i,"%i","INDEX:",0,1,1,2); @@ -3872,6 +3995,6 @@ GUI_TOOLTIP(button,"LSCALAPACK: Ch. 6.59 DEFAULT: FALSE\nIf set scaLAPACK routin /* all done */ vasp_gui_refresh();/*refresh once more*/ GUI_SHOW(vasp_gui.window);/*display*/ - sysenv.refresh_dialog=TRUE; + sysenv.refresh_dialog=TRUE; } From 54cb4e69f00da682f26c652364a9b6c7bce4bc12 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 30 Jul 2018 16:14:39 +0900 Subject: [PATCH 12/56] gui_uspex: prepare unified gui interface XI + fix memory leaks V. --- src/gui_defs.h | 34 ++++++ src/gui_vasp.c | 322 ++++++++++++++++++++++++++++--------------------- 2 files changed, 216 insertions(+), 140 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index 6a52cc3..d16622b 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -260,6 +260,10 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_COMBOBOX_DEL(combobox,index) do{\ gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(combobox),index);\ }while(0) +/*Wipe the combobox (combobox)*/ +#define GUI_COMBOBOX_WIPE(combobox) do{\ + gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(combobox))));\ +}while(0) /*Create a new cell with: * a boxed spin button, which default value is 1 and interval is [1,100], and labeled with text ("caption"). * Due to limitation of GTK, value has to be of double type and not integer (event though it make little sense).*/ @@ -361,6 +365,36 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_CLOSE_ACTION(window,button,function,data) do{\ button=gui_stock_button(GTK_STOCK_CLOSE,function,data,GTK_DIALOG(window)->action_area);\ }while(0) +/*prepare an open-dialog (open_dialog) in the window (window) with the title (title) and an implicit filter with pattern (filter_pattern) and filter title (filter_caption).*/ +#define GUI_PREPARE_OPEN_DIALOG(window,open_dialog,title,filter_pattern,filter_caption) do{\ + GtkFileFilter *_filter = gtk_file_filter_new();\ + gtk_file_filter_add_pattern(_filter,filter_pattern);\ + if(filter_caption!=NULL) gtk_file_filter_set_name (_filter,filter_caption);\ + open_dialog = gtk_file_chooser_dialog_new(title,GTK_WINDOW(window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL);\ + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(open_dialog),_filter);\ +}while(0) +/*prepare an open-folder dialog (open_dialog) in the window (window) with the title (title).*/ +#define GUI_PREPARE_OPEN_FOLDER(window,open_dialog,title) do{\ + open_dialog = gtk_file_chooser_dialog_new(title,GTK_WINDOW(window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL);\ + gtk_file_chooser_set_action(GTK_FILE_CHOOSER(open_dialog),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);\ +}while(0) +/*run the previously open-dialog (open_dialog) and either: + * i) get selected filename (filename) and signal having an answer (have_answer); + * OR + * ii) set filename to NULL and signal absence of answer (have_answer). */ +#define GUI_OPEN_DIALOG_RUN(open_dialog,have_answer,filename) do{\ + if(gtk_dialog_run(GTK_DIALOG(open_dialog)) == GTK_RESPONSE_ACCEPT) {\ + have_answer=TRUE;\ + filename=gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser));\ + }else{\ + have_answer=FALSE;\ + filename=NULL;\ + }\ +}while(0) +/*destroy the open-dialog (open_dialog)*/ +#define GUI_KILL_OPEN_DIALOG(open_dialog) do{\ + gtk_widget_destroy (GTK_WIDGET(open_dialog));\ +}while(0) /*display the dialog (window).*/ #define GUI_SHOW(window) do{\ gtk_widget_show_all(window);\ diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 311fd5e..6e3e221 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -76,7 +76,7 @@ void gui_vasp_init(){ /*********************************************************/ /* Load calculation setting from an included vasprun.xml */ /*********************************************************/ -void load_vasprun_dialog(GtkButton *button, gpointer data){ +void load_vasprun_dialog(void){//IGNORED: GtkButton *button, gpointer data GtkWidget *file_chooser; GtkFileFilter *filter; /*set filter*/ @@ -103,7 +103,7 @@ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filt /**************************/ /* load mpirun executable */ /**************************/ -void load_mpirun_dialog(GtkButton *button, gpointer data){ +void load_mpirun_dialog(void){//IGNORED: GtkButton *button, gpointer data GtkWidget *file_chooser; GtkFileFilter *filter; /*set filter*/ @@ -130,7 +130,7 @@ gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filt /****************************/ /* load the vasp executable */ /****************************/ -void load_vasp_exe_dialog(GtkButton *button, gpointer data){ +void load_vasp_exe_dialog(void){//IGNORED: GtkButton *button, gpointer data GtkWidget *file_chooser; file_chooser = gtk_file_chooser_dialog_new("Select VASP Executable",GTK_WINDOW(vasp_gui.window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL); if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) @@ -151,7 +151,7 @@ void load_vasp_exe_dialog(GtkButton *button, gpointer data){ /*****************************************/ /* point to the path to run the VASP job */ /*****************************************/ -void load_path_dialog(GtkButton *button, gpointer data){ +void load_path_dialog(void){//IGNORED: GtkButton *button, gpointer data GtkWidget *file_chooser; file_chooser=gtk_file_chooser_dialog_new("Select working folder",GTK_WINDOW(vasp_gui.window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL); gtk_file_chooser_set_action (GTK_FILE_CHOOSER(file_chooser),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); @@ -656,7 +656,7 @@ void vasp_gui_refresh(){ /************************************************************/ /* Preload with default parameter from the simple interface */ /************************************************************/ -void vasp_apply_simple(GtkButton *button, gpointer data){ +void vasp_apply_simple(void){//IGNORED: GtkButton *button, gpointer data /*simple interface*/ gint calcul; gint system; @@ -896,7 +896,7 @@ void vasp_apply_simple(GtkButton *button, gpointer data){ /******************/ /* selecting PREC */ /******************/ -void vasp_prec_selected(GtkWidget *w, struct model_pak *model){ +void vasp_prec_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch (index){ @@ -918,7 +918,7 @@ void vasp_prec_selected(GtkWidget *w, struct model_pak *model){ /*****************************************/ /* Toggle use of automatic prec settings */ /*****************************************/ -void prec_toggle(GtkWidget *w, GtkWidget *box){ +void prec_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box gchar *text; if(!(vasp_gui.calc.use_prec)){ /*switch to manual values*/ @@ -940,7 +940,7 @@ void prec_toggle(GtkWidget *w, GtkWidget *box){ /******************/ /* selecting ALGO */ /******************/ -void vasp_algo_selected(GtkWidget *w, struct model_pak *model){ +void vasp_algo_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.ialgo); @@ -979,7 +979,7 @@ void vasp_algo_selected(GtkWidget *w, struct model_pak *model){ /*******************/ /* selecting IALGO */ /*******************/ -void vasp_ialgo_selected(GtkWidget *w, struct model_pak *model){ +void vasp_ialgo_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1019,7 +1019,7 @@ void vasp_ialgo_selected(GtkWidget *w, struct model_pak *model){ /***************/ /* elec toggle */ /***************/ -void elec_toggle(GtkWidget *w, GtkWidget *box){ +void elec_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box gchar *text; if(!(vasp_gui.calc.auto_elec)){ /*switch to manual values*/ @@ -1051,7 +1051,7 @@ void elec_toggle(GtkWidget *w, GtkWidget *box){ /*******************/ /* selecting LREAL */ /*******************/ -void vasp_lreal_selected(GtkWidget *w, struct model_pak *model){ +void vasp_lreal_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1069,7 +1069,7 @@ void vasp_lreal_selected(GtkWidget *w, struct model_pak *model){ /***************/ /* grid toggle */ /***************/ -void grid_toggle(GtkWidget *w, GtkWidget *box){ +void grid_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box gchar *text; if(!(vasp_gui.calc.auto_grid)){ /*switch to manual values*/ @@ -1105,7 +1105,7 @@ void grid_toggle(GtkWidget *w, GtkWidget *box){ /***************************/ /* ismear value is changed */ /***************************/ -void ismear_changed(GtkWidget *w, struct model_pak *model){ +void ismear_changed(GtkWidget *w){//IGNORED: struct model_pak *model gchar *label; GUI_ENTRY_GET_TEXT(w,label); sscanf(label,"%i",&(vasp_gui.calc.ismear)); @@ -1122,7 +1122,7 @@ void ismear_changed(GtkWidget *w, struct model_pak *model){ /*****************************/ /* kspacing value is changed */ /*****************************/ -void kspacing_changed(GtkWidget *w, struct model_pak *model){ +void kspacing_changed(GtkWidget *w){//IGNORED: struct model_pak *model gchar *label; GUI_ENTRY_GET_TEXT(w,label); sscanf(label,"%lf",&(vasp_gui.calc.kspacing)); @@ -1131,21 +1131,21 @@ void kspacing_changed(GtkWidget *w, struct model_pak *model){ /************************/ /* toggle LNONCOLLINEAR */ /************************/ -void lnoncoll_toggle(GtkWidget *w, GtkWidget *box){ +void lnoncoll_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /* unselecting LNONCOLLINEAR automatically unselect LSORBIT */ if(!vasp_gui.calc.non_collinear) GUI_TOGGLE_OFF(vasp_gui.lsorbit); } /******************/ /* toggle LSORBIT */ /******************/ -void lsorbit_toggle(GtkWidget *w, GtkWidget *box){ +void lsorbit_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /* LSORBIT automatically select LNONCOLLINEAR */ if(vasp_gui.calc.lsorbit) GUI_TOGGLE_ON(vasp_gui.lnoncoll); } /*****************/ /* selecting GGA */ /*****************/ -void vasp_gga_selected(GtkWidget *w, struct model_pak *model){ +void vasp_gga_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1165,7 +1165,7 @@ void vasp_gga_selected(GtkWidget *w, struct model_pak *model){ /*********************/ /* selecting METAGGA */ /*********************/ -void vasp_metagga_selected(GtkWidget *w, struct model_pak *model){ +void vasp_metagga_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.cmbj); @@ -1189,7 +1189,7 @@ void vasp_metagga_selected(GtkWidget *w, struct model_pak *model){ /*******************/ /* toggle LMETAGGA */ /*******************/ -void metagga_toggle(GtkWidget *w, GtkWidget *box){ +void metagga_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box if(!vasp_gui.calc.lmetagga){ /*switch to manual values*/ GUI_LOCK(vasp_gui.metagga); @@ -1208,7 +1208,7 @@ void metagga_toggle(GtkWidget *w, GtkWidget *box){ /*******************/ /* toggle L(S)DA+U */ /*******************/ -void ldau_toggle(GtkWidget *w, GtkWidget *box){ +void ldau_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box gchar *text; if(!vasp_gui.calc.ldau){ /*switch to manual values*/ @@ -1247,7 +1247,7 @@ void ldau_toggle(GtkWidget *w, GtkWidget *box){ /***************************/ /* selecting L(S)DA+U type */ /***************************/ -void vasp_ldau_selected(GtkWidget *w, struct model_pak *model){ +void vasp_ldau_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1263,7 +1263,7 @@ void vasp_ldau_selected(GtkWidget *w, struct model_pak *model){ /***************************************/ /* selecting L(S)DA+U output verbosity */ /***************************************/ -void vasp_ldau_print_selected(GtkWidget *w, struct model_pak *model){ +void vasp_ldau_print_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1279,7 +1279,7 @@ void vasp_ldau_print_selected(GtkWidget *w, struct model_pak *model){ /************************************/ /* toggle manual selection of mixer */ /************************************/ -void mixer_toggle(GtkWidget *w, GtkWidget *box){ +void mixer_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box gchar *text; if((vasp_gui.calc.auto_mixer)){ /*switch to manual values*/ @@ -1326,7 +1326,7 @@ void mixer_toggle(GtkWidget *w, GtkWidget *box){ /*******************/ /* selecting mixer */ /*******************/ -void vasp_mixer_selected(GtkWidget *w, struct model_pak *model){ +void vasp_mixer_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.wc); @@ -1350,7 +1350,7 @@ void vasp_mixer_selected(GtkWidget *w, struct model_pak *model){ /***************************/ /* selecting initial mixer */ /***************************/ -void vasp_inimix_selected(GtkWidget *w, struct model_pak *model){ +void vasp_inimix_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1364,7 +1364,7 @@ void vasp_inimix_selected(GtkWidget *w, struct model_pak *model){ /************************/ /* selecting pre-mixing */ /************************/ -void vasp_mixpre_selected(GtkWidget *w, struct model_pak *model){ +void vasp_mixpre_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1380,7 +1380,7 @@ void vasp_mixpre_selected(GtkWidget *w, struct model_pak *model){ /********************/ /* selecting idipol */ /********************/ -void vasp_idipol_selected(GtkWidget *w, struct model_pak *model){ +void vasp_idipol_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); GUI_UNLOCK(vasp_gui.ldipol); @@ -1412,7 +1412,7 @@ void vasp_idipol_selected(GtkWidget *w, struct model_pak *model){ /********************/ /* selecting lorbit */ /********************/ -void vasp_lorbit_selected(GtkWidget *w, struct model_pak *model){ +void vasp_lorbit_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1436,7 +1436,7 @@ void vasp_lorbit_selected(GtkWidget *w, struct model_pak *model){ /********************/ /* selecting ibrion */ /********************/ -void vasp_ibrion_selected(GtkWidget *w, struct model_pak *model){ +void vasp_ibrion_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.tebeg); @@ -1482,7 +1482,7 @@ void vasp_ibrion_selected(GtkWidget *w, struct model_pak *model){ /******************/ /* selecting ISIF */ /******************/ -void vasp_isif_selected(GtkWidget *w, struct model_pak *model){ +void vasp_isif_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; GUI_COMBOBOX_GET(w,index); vasp_gui.calc.isif=index; @@ -1524,7 +1524,7 @@ void vasp_isif_selected(GtkWidget *w, struct model_pak *model){ /****************/ /* isif toggles */ /****************/ -void isif_toggle(GtkWidget *w, GtkWidget *box){ +void isif_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /*recalculate isif function of the user switches*/ if((vasp_gui.rions)&&(!vasp_gui.rshape)&&(!vasp_gui.rvolume)) {if(vasp_gui.calc.isif>2) vasp_gui.calc.isif=2;} else if((vasp_gui.rions)&&(vasp_gui.rshape)&&(vasp_gui.rvolume)) vasp_gui.calc.isif=3; @@ -1564,7 +1564,7 @@ void toggle_poscar_sd(){ /*************************/ /* selecting poscar_free */ /*************************/ -void vasp_poscar_free_selected(GtkWidget *w, struct model_pak *model){ +void vasp_poscar_free_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; gint ix; gchar *text; @@ -1686,7 +1686,7 @@ void toggle_poscar_direct(){ /*************************/ /* selecting poscar atom */ /*************************/ -void vasp_poscar_atoms_selected(GtkWidget *w, struct model_pak *model){ +void vasp_poscar_atoms_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; gchar *text; gdouble x,y,z; @@ -1816,7 +1816,7 @@ void vasp_atom_delete(){ /**************************/ /* selecting kpoints_mode */ /**************************/ -void vasp_kpoints_mode_selected(GtkWidget *w, struct model_pak *model){ +void vasp_kpoints_mode_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; gchar *text; GUI_COMBOBOX_GET(w,index); @@ -1897,7 +1897,7 @@ void vasp_kpoints_mode_selected(GtkWidget *w, struct model_pak *model){ /**********************/ /* selecting a kpoint */ /**********************/ -void vasp_kpoints_kpts_selected(GtkWidget *w, struct model_pak *model){ +void vasp_kpoints_kpts_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; gchar *text; gdouble x,y,z,wt; @@ -2005,7 +2005,7 @@ void toogle_tetra(){ /*************************/ /* selecting tetrahedron */ /*************************/ -void vasp_tetra_selected(GtkWidget *w, struct model_pak *model){ +void vasp_tetra_selected(GtkWidget *w){//IGNORED: struct model_pak *model gint index; gchar *text; gdouble wt; @@ -2111,7 +2111,7 @@ void potcar_get_species(){ sscanf(line," %c%c%c%*s %*s",&(sym[0]),&(sym[1]),&(sym[2])); if((sym[0]=='P')&&(sym[1]=='A')&&(sym[2]=='W')) { vasp_gui.calc.have_paw=TRUE; - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.have_paw),TRUE); + GUI_TOGGLE_ON(vasp_gui.have_paw); } sym[2]='\0'; while(line){ @@ -2126,59 +2126,71 @@ void potcar_get_species(){ } fclose(fp); /*update vasp_gui.simple_species and vasp_gui.potcar_species*/ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.simple_species),g_strdup_printf("%s",vasp_gui.calc.potcar_species)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_species),g_strdup_printf("%s",vasp_gui.calc.potcar_species)); + tamp=g_strdup_printf("%s",vasp_gui.calc.potcar_species); + GUI_ENTRY_TEXT(vasp_gui.simple_species,tamp); + g_free(tamp);tamp=g_strdup_printf("%s",vasp_gui.calc.potcar_species); + GUI_ENTRY_TEXT(vasp_gui.potcar_species,tamp); + g_free(tamp); } /************************************************************************/ /* point to a file where POTCAR information is stored for each elements */ /************************************************************************/ -void load_potcar_file_dialog(GtkButton *button, gpointer data){ - GtkWidget *file_chooser; - GtkFileFilter *filter; -/*set filter*/ - filter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filter, "*POTCAR"); - gtk_file_filter_set_name (filter,"POTCAR files"); - file_chooser = gtk_file_chooser_dialog_new("Select a POTCAR File",GTK_WINDOW(vasp_gui.window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL); -gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filter*/ - if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) - { - char *filename; - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); - if(filename) { - gtk_entry_set_text(GTK_ENTRY(vasp_gui.simple_potcar),g_strdup_printf("%s",filename)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_file),g_strdup_printf("%s",filename)); -/*dont forget to sync!!*/ - VASP_REG_TEXT(potcar_file); - g_free (filename); - potcar_get_species(); - } - } - gtk_widget_destroy (GTK_WIDGET(file_chooser)); +void load_potcar_file_dialog(void){//IGNORED: GtkButton *button, gpointer data + GtkWidget *file_chooser; + gint have_answer; + char *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(vasp_gui.window,file_chooser,"Select a POTCAR File","*POTCAR","POTCAR files"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.simple_potcar,text); + g_free(text);text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.potcar_file,text); + g_free(text); + VASP_REG_TEXT(potcar_file); + g_free (filename); + potcar_get_species(); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } /*****************************************************/ /* register a specific pseudopotential for a species */ /*****************************************************/ -void apply_species_flavor(GtkButton *button, gpointer data){ - gchar *text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.species_flavor)); - gchar *symbol=g_strdup(text); - gchar *flavor=g_strdup(text); +void apply_species_flavor(void){//IGNORED: GtkButton *button, gpointer data + gchar *text; + gchar *symbol; + gchar *flavor; gchar sym[3]; gint idx; gchar *result=NULL; + /**/ + GUI_COMBOBOX_GET_TEXT(vasp_gui.species_flavor,text); if(text==NULL) return;/*nothing selected*/ - if(text[0]=='\0') return;/*nothing selected*/ + symbol=g_strdup(text);/*prepare enough size*/ + flavor=g_strdup(text);/*prepare enough size*/ + if(text[0]=='\0') { + /*nothing selected*/ + goto flavor_end; + } sscanf(text,"%[^:]: %s",symbol,flavor); + g_free(text); text=g_strdup_printf("%s",vasp_gui.calc.potcar_species_flavor); g_free(vasp_gui.calc.potcar_species_flavor); sym[2]='\0'; + /*chemical symbol is at MAX 2 characters*/ if(g_ascii_islower(symbol[1])){/*2 letters*/ sscanf(symbol,"%c%c",&(sym[0]),&(sym[1])); idx=0; while((g_ascii_strncasecmp(&(text[idx]),sym,2)!=0)&&(text[idx]!='\0')) idx++; if(text[idx]=='\0'){ fprintf(stderr,"ERROR in setting POTCAR flavor.\n"); - return;/*this should never happen*/ + /*this should never happen*/ + goto flavor_end; } if(idx!=0) { text[idx]='\0'; @@ -2204,7 +2216,9 @@ void apply_species_flavor(GtkButton *button, gpointer data){ } if(text[idx]=='\0'){ fprintf(stderr,"ERROR in setting POTCAR flavor.\n"); - return;/*this should never happen*/ + /*this should never happen*/ + goto flavor_end; + } if(idx!=0) { text[idx]='\0'; @@ -2220,14 +2234,21 @@ void apply_species_flavor(GtkButton *button, gpointer data){ vasp_gui.calc.potcar_species_flavor=g_strdup_printf("%s%s",result,&(text[idx])); } } + g_free(text);text=g_strdup_printf("%s",vasp_gui.calc.potcar_species_flavor); + GUI_ENTRY_TEXT(vasp_gui.potcar_species_flavor,text); g_free(result); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_species_flavor),g_strdup_printf("%s",vasp_gui.calc.potcar_species_flavor)); +flavor_end: + g_free(text); + g_free(symbol); + g_free(flavor); + return; } /******************************************************/ /* register a species and a flavor from POTCAR FOLDER */ /******************************************************/ #define DEBUG_POTCAR_FOLDER 0 void potcar_folder_register(gchar *item){ + gchar *text; gchar elem[3]; elem[0]=item[0]; if(g_ascii_islower (item[1])) elem[1]=item[1]; @@ -2236,23 +2257,30 @@ void potcar_folder_register(gchar *item){ #if DEBUG_POTCAR_FOLDER fprintf(stdout,"#DBG: REG_ %s as %s \n",item,elem); #endif - VASP_COMBOBOX_ADD(vasp_gui.species_flavor,g_strdup_printf("%s: %s",elem,item)); + text=g_strdup_printf("%s: %s",elem,item); + GUI_COMBOBOX_ADD(vasp_gui.species_flavor,text); + g_free(text); } /**************************************/ /* get information from POTCAR folder */ /**************************************/ void potcar_folder_get_info(){ /*using POTCAR files, given they are not stored in a ZCOMPRESS format*/ - const gchar *path=gtk_entry_get_text(GTK_ENTRY(vasp_gui.potcar_folder)); - GSList *folders=file_dir_list(path,FALSE); + gchar *path; + GSList *folders; gchar *item; gchar sym[3]; + gchar *text; + /**/ + GUI_ENTRY_GET_TEXT(vasp_gui.potcar_folder,path); + folders=file_dir_list(path,FALSE); + g_free(path); vasp_poscar_sync(); #if DEBUG_POTCAR_FOLDER fprintf(stdout,"#DBG: looking for %s\n",vasp_gui.calc.species_symbols); #endif /*wipe all entry in vasp_gui.species_flavor*/ - gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(vasp_gui.species_flavor)))); + GUI_COMBOBOX_WIPE(vasp_gui.species_flavor); sym[2]='\0'; for ( ; folders ; folders=g_slist_next(folders)){ item=g_strdup_printf("%s",(char *)folders->data); @@ -2279,61 +2307,71 @@ void potcar_folder_get_info(){ } g_free(item); } + /*FIXME: wipe before copy?*/ vasp_gui.calc.potcar_species=g_strdup(vasp_gui.calc.species_symbols);/*just copy is enough for now*/ vasp_gui.calc.potcar_species_flavor=g_strdup(vasp_gui.calc.species_symbols);/*same here*/ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.simple_species),g_strdup_printf("%s",vasp_gui.calc.potcar_species)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_species),g_strdup_printf("%s",vasp_gui.calc.potcar_species)); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_species_flavor),g_strdup_printf("%s",vasp_gui.calc.potcar_species_flavor)); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.species_flavor),0); + + text=g_strdup_printf("%s",vasp_gui.calc.potcar_species); + GUI_ENTRY_TEXT(vasp_gui.simple_species,text); + GUI_ENTRY_TEXT(vasp_gui.potcar_species,text); + g_free(text);text=g_strdup_printf("%s",vasp_gui.calc.potcar_species_flavor); + GUI_ENTRY_TEXT(vasp_gui.potcar_species_flavor,text); + g_free(text); + GUI_COMBOBOX_SET(vasp_gui.species_flavor,0); } /***************************************************************/ /* point to a folder where POTCAR are stored for each elements */ /***************************************************************/ -void load_potcar_folder_dialog(GtkButton *button, gpointer data){ - GtkWidget *file_chooser; -file_chooser=gtk_file_chooser_dialog_new("Select the POTCAR folder",GTK_WINDOW(vasp_gui.window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL); - gtk_file_chooser_set_action (GTK_FILE_CHOOSER(file_chooser),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); - if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) - { - char *foldername = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); - if(foldername) { - gtk_entry_set_text(GTK_ENTRY(vasp_gui.potcar_folder),g_strdup_printf("%s",foldername)); - if(vasp_gui.calc.potcar_folder!=NULL) g_free(vasp_gui.calc.potcar_folder); - vasp_gui.calc.potcar_folder=g_strdup_printf("%s",foldername); - g_free (foldername); - potcar_folder_get_info(); - } - } - gtk_widget_destroy (GTK_WIDGET(file_chooser)); +void load_potcar_folder_dialog(void){//IGNORED: GtkButton *button, gpointer data + GtkWidget *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_FOLDER(vasp_gui.window,file_chooser,"Select the POTCAR folder"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.potcar_folder,text); + g_free(text); + if(vasp_gui.calc.potcar_folder!=NULL) g_free(vasp_gui.calc.potcar_folder); + vasp_gui.calc.potcar_folder=g_strdup_printf("%s",filename); + g_free (filename); + potcar_folder_get_info(); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } /*************************************/ /* Select POTCAR information by file */ /*************************************/ -void toggle_potcar_file(GtkWidget *w, GtkWidget *box){ +void toggle_potcar_file(void){//IGNORED: GtkWidget *w, GtkWidget *box vasp_gui.have_potcar_folder=FALSE; - gtk_widget_set_sensitive(vasp_gui.potcar_folder,FALSE); - gtk_widget_set_sensitive(vasp_gui.potcar_folder_button,FALSE); - gtk_widget_set_sensitive(vasp_gui.species_flavor,FALSE); - gtk_widget_set_sensitive(vasp_gui.species_button,FALSE); - gtk_widget_set_sensitive(vasp_gui.potcar_file,TRUE); - gtk_widget_set_sensitive(vasp_gui.potcar_file_button,TRUE); + GUI_LOCK(vasp_gui.potcar_folder); + GUI_LOCK(vasp_gui.potcar_folder_button); + GUI_LOCK(vasp_gui.species_flavor); + GUI_LOCK(vasp_gui.species_button); + GUI_UNLOCK(vasp_gui.potcar_file); + GUI_UNLOCK(vasp_gui.potcar_file_button); } /*************************************/ /* Select POTCAR information by path */ /*************************************/ -void toggle_potcar_folder(GtkWidget *w, GtkWidget *box){ +void toggle_potcar_folder(void){//IGNORED: GtkWidget *w, GtkWidget *box vasp_gui.have_potcar_folder=TRUE; - gtk_widget_set_sensitive(vasp_gui.potcar_file,FALSE); - gtk_widget_set_sensitive(vasp_gui.potcar_file_button,FALSE); - gtk_widget_set_sensitive(vasp_gui.potcar_folder,TRUE); - gtk_widget_set_sensitive(vasp_gui.potcar_folder_button,TRUE); - gtk_widget_set_sensitive(vasp_gui.species_flavor,TRUE); - gtk_widget_set_sensitive(vasp_gui.species_button,TRUE); + GUI_LOCK(vasp_gui.potcar_file); + GUI_LOCK(vasp_gui.potcar_file_button); + GUI_UNLOCK(vasp_gui.potcar_folder); + GUI_UNLOCK(vasp_gui.potcar_folder_button); + GUI_UNLOCK(vasp_gui.species_flavor); + GUI_UNLOCK(vasp_gui.species_button); } /************************************************************************/ -/* tentative to equilibrate the NPAR,NCORE,KPAR with the number of CPUs */ +/* equilibrate NPAR,NCORE,KPAR with the number of CPUs */ /************************************************************************/ -void parallel_eq(GtkWidget *w, GtkWidget *box){ +void parallel_eq(void){//IGNORED: *GtkWidget *w, GtkWidget *box /*parallel equilibration*/ gint np,ncore,kpar; /* no need to sync */ @@ -2343,26 +2381,27 @@ void parallel_eq(GtkWidget *w, GtkWidget *box){ /*we have np CPU*/ if(np==1){ //NCORE=1 ; KPAR=1 - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.ncore),1.0); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpar),1.0); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.ncore),1.0,1.0); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.kpar),1.0,1.0); + GUI_SPIN_SET(vasp_gui.ncore,1.0); + GUI_SPIN_SET(vasp_gui.kpar,1.0); + GUI_SPIN_RANGE(vasp_gui.ncore,1.0,1.0); + GUI_SPIN_RANGE(vasp_gui.kpar,1.0,1.0); /*same for simplified interface*/ - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.simple_ncore),1.0); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.simple_kpar),1.0); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.simple_ncore),1.0,1.0); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.simple_kpar),1.0,1.0); + GUI_SPIN_SET(vasp_gui.simple_ncore,1.0); + GUI_SPIN_SET(vasp_gui.simple_kpar,1.0); + GUI_SPIN_RANGE(vasp_gui.simple_ncore,1.0,1.0); + GUI_SPIN_RANGE(vasp_gui.simple_kpar,1.0,1.0); return; } /* ncore should be [1,ncpu/kpar] */ - if(ncore>((gint)np/kpar)) gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.ncore),(gdouble)((gint)np/kpar)); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.ncore),1.0,(gdouble)((gint)np/kpar)); + if(ncore>((gint)np/kpar)) { + GUI_SPIN_SET(vasp_gui.ncore,(gdouble)((gint)np/kpar)); + GUI_SPIN_SET(vasp_gui.simple_ncore,(gdouble)((gint)np/kpar)); + } + GUI_SPIN_RANGE(vasp_gui.ncore,1.0,(gdouble)((gint)np/kpar)); + GUI_SPIN_RANGE(vasp_gui.simple_ncore,1.0,(gdouble)((gint)np/kpar)); /* kpar can be [1,ncpu] */ - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.kpar),1.0,(gdouble)np); - /*same for the simplified interface*/ - if(ncore>((gint)np/kpar)) gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.simple_ncore),(gdouble)((gint)np/kpar)); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.simple_ncore),1.0,(gdouble)((gint)np/kpar)); - gtk_spin_button_set_range(GTK_SPIN_BUTTON(vasp_gui.simple_kpar),1.0,(gdouble)np); + GUI_SPIN_RANGE(vasp_gui.kpar,1.0,(gdouble)np); + GUI_SPIN_RANGE(vasp_gui.simple_kpar,1.0,(gdouble)np); } /***************************/ /* sync poscar information */ @@ -2701,6 +2740,9 @@ void calc_to_kpoints(FILE *output,vasp_calc_struct calc){ switch (vasp_gui.calc.kpoints_mode){ case VKP_LINE: fprintf(output,"Line-mode\n"); + if(vasp_gui.calc.kpoints_cart) fprintf(output,"Cartesian\n"); + else fprintf(output,"Reciprocal\n"); + break; case VKP_BASIS: case VKP_MAN: if(vasp_gui.calc.kpoints_cart) fprintf(output,"Cartesian\n"); @@ -2801,7 +2843,7 @@ if(!vasp_gui.have_potcar_folder){ if(vasp_gui.calc.potcar_species_flavor==NULL) return; hasend=FALSE; idx=0; - while((text[idx]==' ')) {/*skip trailing space*/ + while((text[idx]==' ')||(text[idx]=='\t')) {/*skip trailing space*/ if(text[idx]=='\0') { fprintf(stderr,"ERROR while reading POTCAR flavors!\n"); g_free(text); @@ -3209,8 +3251,8 @@ GUI_TOOLTIP(vasp_gui.icharg,"ICHARG: Ch. 6.15 DEFAULT 2\nDetermine how the initi GUI_COMBOBOX_SETUP(vasp_gui.algo,0,vasp_algo_selected); GUI_COMBOBOX_SETUP(vasp_gui.ialgo,7,vasp_ialgo_selected); GUI_LOCK(vasp_gui.ialgo); - prec_toggle(NULL,NULL); - elec_toggle(NULL,NULL); + prec_toggle(); + elec_toggle(); /* --- end frame */ /* --- mixing */ GUI_FRAME_NOTE(page,frame,"Mixing"); @@ -3261,7 +3303,7 @@ GUI_TOOLTIP(vasp_gui.wc,"WC: Ch. 6.49 DEFAULT: 1000\nstep weight factor for Broy GUI_COMBOBOX_SETUP(vasp_gui.mixer,3,vasp_mixer_selected); GUI_COMBOBOX_SETUP(vasp_gui.mixpre,1,vasp_mixpre_selected); GUI_COMBOBOX_SETUP(vasp_gui.inimix,1,vasp_inimix_selected); - mixer_toggle(NULL,NULL); + mixer_toggle(); /* --- end frame */ /* --- projector */ GUI_FRAME_NOTE(page,frame,"Projector"); @@ -3307,7 +3349,7 @@ GUI_TOOLTIP(vasp_gui.ngyf,"NGYF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh gri GUI_TOOLTIP(vasp_gui.ngzf,"NGZF: Ch. 6.3 DEFAULT: -\nnumber of fine FFT-mesh grid-points along the z direction."); /* initialize */ GUI_COMBOBOX_SETUP(vasp_gui.lreal,3,vasp_lreal_selected); - grid_toggle(NULL,NULL); + grid_toggle(); /* --- end frame */ /*-------------------*/ @@ -3333,8 +3375,8 @@ GUI_TOOLTIP(vasp_gui.fermwe,"FERMWE: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 explicitl GUI_TEXT_TABLE(table,vasp_gui.fermdo,vasp_gui.calc.fermdo,"FERMDO=",2,4,1,2); GUI_TOOLTIP(vasp_gui.fermdo,"FERDO: Ch. 6.38 DEFAULT -\nFor ISMEAR=-2 and ISPIN=2 sets\noccupancy for down spin of each band."); /* initialize */ - GUI_ENTRY_CHANGE(vasp_gui.ismear,ismear_changed,data);/*NEW: ELECT-I ismear -> KPOINTS ismear*/ - GUI_ENTRY_CHANGE(vasp_gui.kspacing,kspacing_changed,data);/*NEW: ELECT-I kspacing -> KPOINTS kspacing*/ + GUI_ENTRY_CHANGE(vasp_gui.ismear,ismear_changed,NULL);/*NEW: ELECT-I ismear -> KPOINTS ismear*/ + GUI_ENTRY_CHANGE(vasp_gui.kspacing,kspacing_changed,NULL);/*NEW: ELECT-I kspacing -> KPOINTS kspacing*/ /* --- end frame */ /* --- spin */ GUI_FRAME_NOTE(page,frame,"Spin"); @@ -3421,8 +3463,8 @@ GUI_TOOLTIP(vasp_gui.ldauj,"LDAUJ: Ch. 6.70 DEFAULT: -\nSets effective on-site E GUI_COMBOBOX_SETUP(vasp_gui.metagga,3,vasp_metagga_selected); GUI_COMBOBOX_SETUP(vasp_gui.ldau,1,vasp_ldau_selected); GUI_COMBOBOX_SETUP(vasp_gui.ldau_print,0,vasp_ldau_print_selected); - metagga_toggle(NULL,NULL);/*initialize TODO: move to end*/ - ldau_toggle(NULL,NULL);/*initialize TODO: move to end*/ + metagga_toggle(); + ldau_toggle(); /* --- end frame */ /* --- dipole */ GUI_FRAME_NOTE(page,frame,"Dipole"); @@ -3729,7 +3771,7 @@ if((vasp_gui.calc.poscar_free==VPF_FIXED)||(vasp_gui.calc.poscar_free==VPF_FREE) } /* (re)initialize */ toggle_poscar_sd(NULL,NULL); - vasp_poscar_free_selected(vasp_gui.poscar_free,NULL); + vasp_poscar_free_selected(vasp_gui.poscar_free); /* --- end frame */ /*-------------------*/ @@ -3838,13 +3880,13 @@ GUI_TOOLTIP(vasp_gui.tetra_c,"3rd corner of the tetrahedron (C) in k-point index GUI_ENTRY_TABLE(table,vasp_gui.tetra_d,vasp_gui.calc.tetra_d,"%i","PtD:",5,6,2,3); GUI_TOOLTIP(vasp_gui.tetra_d,"4th corner of the tetrahedron (D) in k-point index."); /* initialize */ - GUI_ENTRY_CHANGE(vasp_gui.ismear_3,ismear_changed,data); - GUI_ENTRY_CHANGE(vasp_gui.kspacing_3,kspacing_changed,data); + GUI_ENTRY_CHANGE(vasp_gui.ismear_3,ismear_changed,NULL); + GUI_ENTRY_CHANGE(vasp_gui.kspacing_3,kspacing_changed,NULL); GUI_COMBOBOX_SETUP(vasp_gui.kpoints_mode,vasp_gui.calc.kpoints_mode,vasp_kpoints_mode_selected); GUI_COMBOBOX_SETUP(vasp_gui.kpoints_kpts,0,vasp_kpoints_kpts_selected); GUI_COMBOBOX_SETUP(vasp_gui.tetra,0,vasp_tetra_selected); toogle_tetra(); - ismear_changed(vasp_gui.ismear_3,data);/*necessary*/ + ismear_changed(vasp_gui.ismear_3);/*necessary*/ /* --- end frame */ /* TODO: import KPOINTS/IBZKPT file*/ @@ -3883,10 +3925,10 @@ GUI_TOOLTIP(vasp_gui.potcar_file,"POTCAR file, including its full path."); GUI_TOOLTIP(vasp_gui.potcar_folder,"Full PATH to the POTCAR sub-directories."); /* 3rd line */ GUI_COMBOBOX_TABLE(table,vasp_gui.species_flavor,"FLAVOR:",2,3,2,3); - GUI_OPEN_BUTTON_TABLE(table,vasp_gui.species_button,apply_species_flavor,3,4,2,3); + GUI_APPLY_BUTTON_TABLE(table,vasp_gui.species_button,apply_species_flavor,3,4,2,3); GUI_TOOLTIP(vasp_gui.species_flavor,"When Using PATH method, for each species a choice\nbetween different pseudopotential setting (flavors) exists\nEx: _h hard, _s soft _pv include pseudo-core valence, etc."); /* initialize */ - toggle_potcar_file(NULL,NULL); + toggle_potcar_file(); /* --- end frame */ /* --- POTCAR results */ GUI_FRAME_NOTE(page,frame,"POTCAR results"); From d460348d4fd7d11796adbb8055f700bcfdd7e6ee Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 30 Jul 2018 19:20:31 +0900 Subject: [PATCH 13/56] gui_uspex: prepare unified gui interface XII + fix memory leaks VI. --- src/gui_defs.h | 11 ++ src/gui_vasp.c | 327 +++++++++++++++++++++++++++---------------------- 2 files changed, 193 insertions(+), 145 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index d16622b..d1ad259 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -130,6 +130,9 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_PAGE_CHANGE(notebook,function,data) do{\ g_signal_connect(GTK_NOTEBOOK(notebook),"switch-page",GTK_SIGNAL_FUNC(function),data);\ }while(0) +#define GUI_NOTE_PAGE_NUMBER(notebook,number) do{\ + number = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));\ +}while(0) /*******************/ /* FRAME INTERFACE */ /*******************/ @@ -256,6 +259,10 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_COMBOBOX_ADD_TEXT(combobox,index,text) do{\ gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(combobox),index,text);\ }while(0) +/*Prepend text ("text") in combobox (combobox).*/ +#define GUI_COMBOBOX_PREPEND_TEXT(combobox,text) do{\ + gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(combobox),text);\ +}while(0) /*Delete combobox (combobox) text at position index (index)*/ #define GUI_COMBOBOX_DEL(combobox,index) do{\ gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(combobox),index);\ @@ -399,3 +406,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_SHOW(window) do{\ gtk_widget_show_all(window);\ }while(0) +/*close window (window)*/ +#define GUI_CLOSE(window) do{\ + gtk_widget_destroy(window);\ +}while(0) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 6e3e221..6d96788 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -77,97 +77,94 @@ void gui_vasp_init(){ /* Load calculation setting from an included vasprun.xml */ /*********************************************************/ void load_vasprun_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; - GtkFileFilter *filter; -/*set filter*/ - filter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filter, "*vasprun.xml"); - gtk_file_filter_set_name (filter,"vasprun.xml files"); - file_chooser = gtk_file_chooser_dialog_new("Select a vasprun.xml File",GTK_WINDOW(vasp_gui.window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL); -gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filter*/ - if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) - { - char *filename; - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); - if(filename) { - gchar *text=g_strdup_printf("%s",filename); - GUI_ENTRY_TEXT(vasp_gui.file_entry,text); - g_free(text); - vasprun_update(filename,&vasp_gui.calc);/*<- update everything according to the new vasprun.xml*/ - g_free (filename); - vasp_gui_refresh();/*refresh GUI with new vasp_gui.calc*/ - } - } - gtk_widget_destroy (GTK_WIDGET(file_chooser)); + GtkWidget *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(vasp_gui.window,file_chooser,"Select a vasprun.xml File","*vasprun.xml","vasprun.xml files"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.file_entry,text); + g_free(text); + vasprun_update(filename,&vasp_gui.calc);/*<- update everything according to the new vasprun.xml*/ + g_free (filename); + vasp_gui_refresh();/*refresh GUI with new vasp_gui.calc*/ + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } /**************************/ /* load mpirun executable */ /**************************/ void load_mpirun_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; - GtkFileFilter *filter; -/*set filter*/ - filter = gtk_file_filter_new(); - gtk_file_filter_add_pattern(filter, "mpirun"); - gtk_file_filter_set_name (filter,"mpirun exec"); - file_chooser = gtk_file_chooser_dialog_new("Select mpirun Executable",GTK_WINDOW(vasp_gui.window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL); -gtk_file_chooser_add_filter (GTK_FILE_CHOOSER(file_chooser),filter);/*apply filter*/ - if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) - { - char *filename; - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); - if(filename) { - gchar *text=g_strdup_printf("%s",filename); - GUI_ENTRY_TEXT(vasp_gui.job_mpirun,text); - g_free(text); - /* sync job_mpirun */ - VASP_REG_TEXT(job_mpirun); - g_free (filename); - } - } - gtk_widget_destroy (GTK_WIDGET(file_chooser)); + GtkWidget *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(vasp_gui.window,file_chooser,"Select mpirun Executable","mpirun","mpirun exec"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.job_mpirun,text); + g_free(text); + VASP_REG_TEXT(job_mpirun); + g_free (filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } /****************************/ /* load the vasp executable */ /****************************/ void load_vasp_exe_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; - file_chooser = gtk_file_chooser_dialog_new("Select VASP Executable",GTK_WINDOW(vasp_gui.window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL); - if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) - { - char *filename; - filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); - if(filename) { - gchar *text=g_strdup_printf("%s",filename); - GUI_ENTRY_TEXT(vasp_gui.job_vasp_exe,text); - g_free(text); - /*sync job_vasp_exe*/ - VASP_REG_TEXT(job_vasp_exe); - g_free (filename); - } - } - gtk_widget_destroy (GTK_WIDGET(file_chooser)); + GtkWidget *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(vasp_gui.window,file_chooser,"Select VASP Executable","vasp","vasp_exec"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.job_vasp_exe,text); + g_free(text); + VASP_REG_TEXT(job_vasp_exe); + g_free (filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } /*****************************************/ /* point to the path to run the VASP job */ /*****************************************/ void load_path_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; -file_chooser=gtk_file_chooser_dialog_new("Select working folder",GTK_WINDOW(vasp_gui.window),GTK_FILE_CHOOSER_ACTION_OPEN,GTK_STOCK_CANCEL,GTK_RESPONSE_CANCEL,GTK_STOCK_OPEN,GTK_RESPONSE_ACCEPT,NULL); - gtk_file_chooser_set_action (GTK_FILE_CHOOSER(file_chooser),GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); - if (gtk_dialog_run (GTK_DIALOG (file_chooser)) == GTK_RESPONSE_ACCEPT) - { - char *foldername = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser)); - if(foldername) { - gchar *text=g_strdup_printf("%s",foldername); - GUI_ENTRY_TEXT(vasp_gui.job_path,text); - g_free(text); - /*sync job_path*/ - VASP_REG_TEXT(job_path); - g_free (foldername); - } - } - gtk_widget_destroy (GTK_WIDGET(file_chooser)); + GtkWidget *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_FOLDER(vasp_gui.window,file_chooser,"Select working folder"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(vasp_gui.job_path,text); + g_free(text); + VASP_REG_TEXT(job_path); + g_free (filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } /*********************************************/ /* refresh the GUI with value from vasp_gui.calc */ @@ -1619,7 +1616,7 @@ void vasp_poscar_free_selected(GtkWidget *w){//IGNORED: struct model_pak *model /* poscar_direct toggle */ /************************/ void toggle_poscar_direct(){ - gint index;//=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms));/*PUSH*/ + gint index; gint idx=0; gchar *text; gchar *tamp; @@ -2416,45 +2413,50 @@ void vasp_poscar_sync(){ if(vasp_gui.poscar_dirty==FALSE) return;/*ne need to update*/ /* pass_1: GROUP atom list by atom types */ idx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); while(g_ascii_strcasecmp(text,"ADD atom")!=0){ sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); + g_free(text); jdx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),jdx); - text2=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,jdx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text2); while(g_ascii_strcasecmp(text2,"ADD atom")!=0){ /**/ sscanf(text2,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(symbol[0])); if(g_ascii_strcasecmp(vasp_gui.calc.poscar_symbol,symbol) == 0){ - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),jdx); - gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),text2); + GUI_COMBOBOX_DEL(vasp_gui.poscar_atoms,jdx); + GUI_COMBOBOX_PREPEND_TEXT(vasp_gui.poscar_atoms,text2); idx++; } + g_free(text2); jdx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),jdx); - text2=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,jdx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text2); } + g_free(text2); idx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); } + g_free(text); /* pass_2: REORDER atom list <- useful for 'consistent' ordering*/ idx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); while(g_ascii_strcasecmp(text,"ADD atom")!=0){ - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),idx); - gtk_combo_box_text_prepend_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),text); + GUI_COMBOBOX_DEL(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_PREPEND_TEXT(vasp_gui.poscar_atoms,text); + g_free(text); idx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); } /* pass_3: SETUP unexposed properties (fix atom index)*/ idx=0;jdx=0;vasp_gui.calc.electron_total=0; vasp_gui.calc.species_total=1; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); tamp=g_strdup_printf(" %s",vasp_gui.calc.poscar_symbol); tamp2=g_strdup_printf(" "); @@ -2463,8 +2465,11 @@ void vasp_poscar_sync(){ sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(symbol[0])); text2=g_strdup(text);/*to get enough space*/ sscanf(text,"%[^!]%*s",text2); - gtk_combo_box_insert_text(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx,g_strdup_printf("%s! atom: %i (%s)",text2,idx,symbol)); - gtk_combo_box_text_remove(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms),idx+1); + g_free(text); + text=g_strdup_printf("%s! atom: %i (%s)",text2,idx,symbol); + GUI_COMBOBOX_ADD_TEXT(vasp_gui.poscar_atoms,idx,text); + g_free(text); + GUI_COMBOBOX_DEL(vasp_gui.poscar_atoms,idx+1); g_free(text2); vasp_gui.calc.electron_total+=elem_symbol_test(symbol); if(g_ascii_strcasecmp(vasp_gui.calc.poscar_symbol,symbol) != 0) { @@ -2481,8 +2486,8 @@ void vasp_poscar_sync(){ } idx++; jdx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); } vasp_gui.calc.atoms_total=idx;/*so we have the total number of atoms*/ /*we need to get the last jdx*/ @@ -2491,46 +2496,69 @@ void vasp_poscar_sync(){ tamp2=text; if(vasp_gui.calc.species_symbols!=NULL) g_free(vasp_gui.calc.species_symbols); if(vasp_gui.calc.species_numbers!=NULL) g_free(vasp_gui.calc.species_numbers); - vasp_gui.calc.species_symbols=g_strdup(tamp);g_free(tamp); - vasp_gui.calc.species_numbers=g_strdup(tamp2);g_free(tamp2); + vasp_gui.calc.species_symbols=g_strdup(tamp); + g_free(tamp); + vasp_gui.calc.species_numbers=g_strdup(tamp2); + g_free(tamp2); vasp_gui.poscar_dirty=FALSE; } /************************/ /* Switch notebook page */ /************************/ -void vasp_gui_page_switch(GtkNotebook *notebook,GtkWidget *page,guint page_num,gpointer user_data){ +void vasp_gui_page_switch(GtkNotebook *notebook,GtkWidget *page,guint page_num){//IGNORED: gpointer user_data + gint from_page; + gchar *text; /* some (few) values need to be updated from a page to another*/ - vasp_gui.cur_page=page_num;/*TODO: for (adv.)*/ + GUI_NOTE_PAGE_NUMBER(notebook,from_page); + if(from_page==(gint)page_num) return;/*not moved*/ + vasp_gui.cur_page=page_num; + GUI_LOCK(page); if(page_num==VASP_PAGE_SIMPLIFIED){ vasp_poscar_sync();/*we need to know species_symbols*/ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.simple_poscar),g_strdup_printf("%s",vasp_gui.calc.species_symbols)); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.simple_np),vasp_gui.calc.job_nproc); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.simple_ncore),vasp_gui.calc.ncore); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.simple_kpar),vasp_gui.calc.kpar); + text=g_strdup_printf("%s",vasp_gui.calc.species_symbols); + GUI_ENTRY_TEXT(vasp_gui.simple_poscar,text); + g_free(text); + GUI_SPIN_SET(vasp_gui.simple_np,vasp_gui.calc.job_nproc); + GUI_SPIN_SET(vasp_gui.simple_ncore,vasp_gui.calc.ncore); + GUI_SPIN_SET(vasp_gui.simple_kpar,vasp_gui.calc.kpar); } else if(page_num==VASP_PAGE_ELECTRONIC){ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ismear),g_strdup_printf("%i",vasp_gui.calc.ismear)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.kgamma),vasp_gui.calc.kgamma); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kspacing),g_strdup_printf("%.4lf",vasp_gui.calc.kspacing)); + /*can be changed from anywhere*/ + text=g_strdup_printf("%i",vasp_gui.calc.ismear); + GUI_ENTRY_TEXT(vasp_gui.ismear,text); + g_free(text); + if(vasp_gui.calc.kgamma) GUI_TOGGLE_ON(vasp_gui.kgamma); + else GUI_TOGGLE_OFF(vasp_gui.kgamma); + text=g_strdup_printf("%.4lf",vasp_gui.calc.kspacing); + GUI_ENTRY_TEXT(vasp_gui.kspacing,text); + g_free(text); } else if (page_num==VASP_PAGE_IONIC){ vasp_poscar_sync();/*arrange poscar atom values*/ } else if (page_num==VASP_PAGE_KPOINTS){ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.ismear_3),g_strdup_printf("%i",vasp_gui.calc.ismear)); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(vasp_gui.kgamma_3),vasp_gui.calc.kgamma); - gtk_entry_set_text(GTK_ENTRY(vasp_gui.kspacing_3),g_strdup_printf("%.4lf",vasp_gui.calc.kspacing)); - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_mode),vasp_gui.calc.kpoints_mode); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kx),vasp_gui.calc.kpoints_kx); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_ky),vasp_gui.calc.kpoints_ky); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpoints_kz),vasp_gui.calc.kpoints_kz); + text=g_strdup_printf("%i",vasp_gui.calc.ismear); + GUI_ENTRY_TEXT(vasp_gui.ismear_3,text); + g_free(text); + if(vasp_gui.calc.kgamma) GUI_TOGGLE_ON(vasp_gui.kgamma_3); + else GUI_TOGGLE_OFF(vasp_gui.kgamma_3); + text=g_strdup_printf("%.4lf",vasp_gui.calc.kspacing); + GUI_ENTRY_TEXT(vasp_gui.kspacing_3,text); + g_free(text); + GUI_COMBOBOX_SET(vasp_gui.kpoints_mode,vasp_gui.calc.kpoints_mode); + GUI_SPIN_SET(vasp_gui.kpoints_kx,vasp_gui.calc.kpoints_kx); + GUI_SPIN_SET(vasp_gui.kpoints_ky,vasp_gui.calc.kpoints_ky); + GUI_SPIN_SET(vasp_gui.kpoints_kz,vasp_gui.calc.kpoints_kz); toogle_tetra();/*in case we need*/ } else if (page_num==VASP_PAGE_POTCAR){ vasp_poscar_sync();/*we need to know species_symbols*/ - gtk_entry_set_text(GTK_ENTRY(vasp_gui.poscar_species),g_strdup_printf("%s",vasp_gui.calc.species_symbols)); + text=g_strdup_printf("%s",vasp_gui.calc.species_symbols); + GUI_ENTRY_TEXT(vasp_gui.poscar_species,text); + g_free(text); } else if (page_num==VASP_PAGE_EXEC){ - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.job_nproc),vasp_gui.calc.job_nproc); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.ncore),vasp_gui.calc.ncore); - gtk_spin_button_set_value(GTK_SPIN_BUTTON(vasp_gui.kpar),vasp_gui.calc.kpar); + GUI_SPIN_SET(vasp_gui.job_nproc,vasp_gui.calc.job_nproc); + GUI_SPIN_SET(vasp_gui.ncore,vasp_gui.calc.ncore); + GUI_SPIN_SET(vasp_gui.kpar,vasp_gui.calc.kpar); } + GUI_UNLOCK(page); /*to be continued...*/ } /**********************************************************/ @@ -2686,12 +2714,13 @@ void vasp_gui_sync(){ /* convert vasp structure to POSCAR (not gui_free) */ /***************************************************/ void calc_to_poscar(FILE *output,vasp_calc_struct calc){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms)); + gint index; gchar *text; gdouble x,y,z; gchar tx,ty,tz; gint idx; /* generate a VASP5 POSCAR file */ + GUI_COMBOBOX_GET(vasp_gui.poscar_atoms,index);/*PUSH*/ if(calc.name!=NULL) fprintf(output,"%s ",calc.name); else fprintf(output,"UNNAMED MODEL "); fprintf(output,"! GENERATED BY GDIS %4.2f.%d (C) %d\n",VERSION,PATCH,YEAR); @@ -2707,29 +2736,32 @@ void calc_to_poscar(FILE *output,vasp_calc_struct calc){ if(calc.poscar_direct) fprintf(output,"Direct\n"); else fprintf(output,"Cartesian\n"); idx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); while(g_ascii_strcasecmp(text,"ADD atom")!=0){ /*get each line*/ sscanf(text,"%lf %lf %lf %c %c %c %*s",&x,&y,&z,&tx,&ty,&tz); + g_free(text); fprintf(output," % .8lf % .8lf % .8lf %c %c %c\n",x,y,z,tx,ty,tz); idx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.poscar_atoms)); - } - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.poscar_atoms),index); + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); + } + g_free(text);/*free "ADD atom"*/ + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,index);/*PULL*/ } /****************************************************/ /* convert vasp structure to KPOINTS (not gui_free) */ /****************************************************/ void calc_to_kpoints(FILE *output,vasp_calc_struct calc){ - gint index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts)); + gint index; gchar *text; gdouble x,y,z,wt; gint a,b,c,d; gint idx; /* generate a VASP KPOINTS file */ + GUI_COMBOBOX_GET(vasp_gui.kpoints_kpts,index);/*PUSH*/ if(calc.name!=NULL) fprintf(output,"%s ",calc.name); else fprintf(output,"UNNAMED MODEL "); fprintf(output,"! GENERATED BY GDIS %4.2f.%d (C) %d\n",VERSION,PATCH,YEAR); @@ -2767,8 +2799,8 @@ void calc_to_kpoints(FILE *output,vasp_calc_struct calc){ } /*print all coordinates*/ idx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.kpoints_kpts)); + GUI_COMBOBOX_SET(vasp_gui.kpoints_kpts,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.kpoints_kpts,text); while(g_ascii_strcasecmp(text,"ADD kpoint")!=0){ if(vasp_gui.calc.kpoints_mode==VKP_MAN) { sscanf(text,"%lf %lf %lf %lf ! kpoint: %*i",&x,&y,&z,&wt); @@ -2777,29 +2809,33 @@ void calc_to_kpoints(FILE *output,vasp_calc_struct calc){ sscanf(text,"%lf %lf %lf ! kpoint: %*i",&x,&y,&z); fprintf(output,"%lf %lf %lf ! kpoint: %i\n",x,y,z,idx+1); } + g_free(text); idx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.kpoints_kpts)); + GUI_COMBOBOX_SET(vasp_gui.kpoints_kpts,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.kpoints_kpts,text); } + g_free(text);/*free "ADD kpoint"*/ /*return to previous postition*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.kpoints_kpts),index); + GUI_COMBOBOX_SET(vasp_gui.kpoints_kpts,index);/*PULL*/ /*print all tetrahedron (if any)*/ if(!vasp_gui.calc.kpoints_tetra) return; fprintf(output,"Tetrahedron\n"); fprintf(output,"%i %lf\n",vasp_gui.calc.tetra_total,vasp_gui.calc.tetra_volume); - index=gtk_combo_box_get_active(GTK_COMBO_BOX(vasp_gui.tetra)); + GUI_COMBOBOX_GET(vasp_gui.tetra,index);/*PUSH*/ idx=0; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.tetra),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.tetra)); + GUI_COMBOBOX_SET(vasp_gui.tetra,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.tetra,text); while(g_ascii_strcasecmp(text,"ADD tetrahedron")!=0){ sscanf(text,"%lf %i %i %i %i ! tetrahedron: %*i",&wt,&a,&b,&c,&d); fprintf(output,"%lf %i %i %i %i ! tetrahedron: %i\n",wt,a,b,c,d,idx+1); + g_free(text); idx++; - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.tetra),idx); - text=gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(vasp_gui.tetra)); + GUI_COMBOBOX_SET(vasp_gui.tetra,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.tetra,text); } + g_free(text);/*free "ADD tetrahedron"*/ /*return to previous postition*/ - gtk_combo_box_set_active(GTK_COMBO_BOX(vasp_gui.tetra),index); + GUI_COMBOBOX_SET(vasp_gui.tetra,index);/*PULL*/ } /*************************************/ /* append one POTCAR file to another */ @@ -2873,6 +2909,7 @@ if(!vasp_gui.have_potcar_folder){ ptr=&(text[idx]); } g_free(text); + if(vasp_gui.calc.potcar_file!=NULL) g_free(vasp_gui.calc.potcar_file); vasp_gui.calc.potcar_file=g_strdup_printf("%s/POTCAR",vasp_gui.calc.job_path); } /*that's all folks*/ @@ -2933,7 +2970,6 @@ gint save_vasp_calc(){ vasp_gui.calc_to_incar(stdout,vasp_gui.calc); calc_to_poscar(stdout,vasp_gui.calc); calc_to_kpoints(stdout,vasp_gui.calc); - #endif return 0; } @@ -2946,7 +2982,7 @@ void vasp_cleanup(){ /*****************************************/ /* Execute or enqueue a vasp calculation */ /*****************************************/ -void run_vasp_exec(vasp_exec_struct *vasp_exec,struct task_pak *task){ +void run_vasp_exec(vasp_exec_struct *vasp_exec){//IGNORED: struct task_pak *task /* Execute a vasp task TODO distant job */ gchar *cmd; gchar *cwd;/*for push/pull*/ @@ -3013,12 +3049,12 @@ void exec_calc(){ /*prepend to calc list*/ sysenv.vasp_calc_list = g_slist_prepend (sysenv.vasp_calc_list,vasp_exec); /*launch vasp in a task*/ - gtk_widget_set_sensitive(vasp_gui.button_save,FALSE); - gtk_widget_set_sensitive(vasp_gui.button_exec,FALSE); + GUI_LOCK(vasp_gui.button_save); + GUI_LOCK(vasp_gui.button_exec); task_new("VASP", &run_vasp_exec,vasp_exec,&cleanup_vasp_exec,vasp_exec,sysenv.active_model); /*when task is launched, close dialog*/ vasp_cleanup(); - gtk_widget_destroy(vasp_gui.window); + GUI_CLOSE(vasp_gui.window); } /********************************/ /* Quit vasp calculation dialog */ @@ -4035,6 +4071,7 @@ GUI_TOOLTIP(button,"LSCALAPACK: Ch. 6.59 DEFAULT: FALSE\nIf set scaLAPACK routin /* connect to signals */ GUI_PAGE_CHANGE(notebook,vasp_gui_page_switch,NULL); /* all done */ + vasp_poscar_sync(); vasp_gui_refresh();/*refresh once more*/ GUI_SHOW(vasp_gui.window);/*display*/ sysenv.refresh_dialog=TRUE; From 28d1de9f05bcbfd36dd779d70bf0ce651bbd568e Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 2 Aug 2018 18:45:09 +0900 Subject: [PATCH 14/56] gui_uspex: prepare unified gui interface (last) + fixes + uspex parameters I --- src/file_uspex.c | 10 +- src/file_uspex.h | 146 +++++++++++++- src/gl_graph.c | 4 +- src/gui_defs.h | 11 ++ src/gui_vasp.c | 130 +++++++------ src/gui_vasp.h | 489 ++++++++++++++++++----------------------------- 6 files changed, 417 insertions(+), 373 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 762bbea..4b5a2d8 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -65,7 +65,7 @@ gint read_parameter_uspex(gchar *filename, struct model_pak *model){ gchar *line=NULL; gchar *ptr; gint idx; - uspex_calc_struct *uspex_calc=model->uspex; + uspex_output_struct *uspex_calc=model->uspex; /* specific */ gchar method; /*start*/ @@ -185,7 +185,7 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ long int vfpos; gchar *line=NULL; gchar tmp[64]; - uspex_calc_struct *uspex_calc=model->uspex; + uspex_output_struct *uspex_calc=model->uspex; /* specific */ gint idx=0; gchar *ptr; @@ -306,7 +306,7 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ gdouble min_F=0.; gdouble max_E; gchar *atoms; - uspex_calc_struct *uspex_calc; + uspex_output_struct *uspex_calc; /* checks */ g_return_val_if_fail(model != NULL, 1); g_return_val_if_fail(filename != NULL, 2); @@ -318,7 +318,7 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ } /*allocs*/ if(model->uspex!=NULL) g_free(model->uspex); - model->uspex=g_malloc(sizeof(uspex_calc_struct)); + model->uspex=g_malloc(sizeof(uspex_output_struct)); uspex_calc=model->uspex; /* TODO: check that selected file is OUTPUT.txt */ vf = fopen(filename, "rt"); @@ -979,7 +979,7 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UC.i } gint read_frame_uspex(FILE *vf, struct model_pak *model){ gchar *line; - uspex_calc_struct *uspex_calc=model->uspex; + uspex_output_struct *uspex_calc=model->uspex; long int vfpos;/*to counter _BUG_ where loading a raw frame does not update model->cur_frame*/ gchar *ptr; gint idx=0; diff --git a/src/file_uspex.h b/src/file_uspex.h index 81e08c6..6105b8e 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -39,7 +39,7 @@ typedef struct { gdouble volume; /*total volume*/ } uspex_individual; -/* global calculation structure */ +/* global output structure */ typedef struct { /*name*/ gchar *name; @@ -54,7 +54,6 @@ typedef struct { /* optimization */ gint opt_type; gboolean have_fitness; - /*structures*/ gint num_gen; gint num_struct; @@ -70,6 +69,148 @@ typedef struct { gpointer graph; gpointer graph_best; gpointer graph_comp; +} uspex_output_struct; +/* USPEX calculation structure */ +typedef struct { +/*additional controls*/ + gchar *name; /*the job name*/ + gint special; /*special tag*/ + uspex_output_struct ouput; /*output structure (once/if output is loaded)*/ +/*4.1 Type of run & System*/ + uspex_method calculationMethod; /*supported calculation methods*/ + gint calculationType; /*supported calculation types*/ + gint _calctype_dim; /*HIDDEN: X.. digit in calculation type: dimension*/ + gboolean _calctype_mol; /*HIDDEN: .X. digit in calculation type: molecular*/ + gboolean _calctype_var; /*HIDDEN: ..X digit in calculation type: variable composition*/ + gint optType; /* optimization property*/ + gint *atomType; /*atomic number of each species*/ + gint *numSpecies; /*number of species for each type*/ + gdouble ExternalPressure; /*external pressure*/ + gint valences; /*valence for each species*/ + gdouble *goodBonds; /*minimum bond valences*/ + gboolean checkMolecules; /*check molecules*/ + gboolean checkConnectivity; /*check connectivity*/ +/*4.2 Population*/ + gint populationSize; /*number of structure in each generation*/ + gint initialPopSize; /*number of structure in initial generation*/ + gint numGenerations; /*maximum number of generation*/ + gint stopCrit; /*stop criterion (max generation with same lowest structure)*/ +/*4.3 Survival of the fittest & Selection*/ + gdouble bestFrac; /*fraction of structures in current generation used for producing the next*/ + gint keepBestHM; /*number of surviving best structures*/ + gboolean reoptOld; /*reoptimization of survivors*/ +/*4.4 Structure generation and variation operators*/ + gchar *symmetries; /*possible symmetries*/ + gdouble fracGene; /*fraction of structures generated by heredity*/ + gdouble fracRand; /*fraction of structures generated randomly*/ + gdouble fracPerm; /*fraction of structures generated by permutation*/ + gdouble fracAtomsMut; /*fraction of structures generated by softmutation*/ + gdouble fracRotMut; /*fraction of structures generated by orientation mutation*/ + gdouble fracLatMut; /*fraction of structures generated by lattice mutation*/ + gint howManySwaps; /*number of pairwise swaps*/ + gchar *specificSwaps; /*which atoms are swapped*/ + gdouble mutationDegree; /*max displacement (Ang) in softmutation*/ + gdouble mutationRate; /*standard deviation in the strain matrix for lattice mutation*/ + gdouble DisplaceInLatmutation; /*max displacement in sofmutation of lattice mutation*/ + gboolean autofrac; /*automatic evolution of variation operators*/ +/*4.5 Constrains*/ + gdouble minVectorLength; /*minimum length of a cell parameter*/ + gdouble *IonDistances; /*triangular-matrix of the minimum allowed interatomic distances*/ + gint constraint_enhancement; /*allow c_e times stricter constraints of IonDistances*/ + gdouble *MolCenters; /*triangular-matrix of minimal distances between centers of molecules*/ +/*4.6 Cell*/ + gdouble *Latticevalues; /*initial volume/parameter of the unit cell*/ + gint splitInto; /*number of subcells into which unit cell is split*/ +/*4.7 Restart*/ + /*Restart is unsupported*/ +/*4.8 Ab initio calculations*/ + gint _num_opt_steps; /*HIDDEN: number of optimization steps*/ + gint *abinitioCode; /*calculation code used for each optimization steps*/ + gdouble KresolStart; /*reciprocal-space resolution (2*pi*ang-1) for k-points generation*/ + gdouble *vacuumSize; /*amount of vacuum added at each optimization step*/ + gint numParallelCalcs; /*number of structure relaxations at a time (in parallel)*/ + gchar *commandExecutable; /*executable file/command for each optimization step*/ + gint whichCluster; /*type of job-submission*/ + gchar *remoteFolder; /*remote folder where calcualtion is performed (whichCluster=2)*/ + gboolean PhaseDiagram; /*calculate a crude phase diagram w/ (rough) transition pressure*/ +/*4.9 fingerprint*/ + gdouble RmaxFing; /*the distance cutoff (Ang)*/ + gdouble deltaFing; /*discretization (Ang) of fingerprint function*/ + gdouble sigmaFing; /*gaussian broadening of interatomic distances*/ +/*4.10 Antiseed*/ + gint antiSeedsActivation; /*generation at which antiseeds will be active*/ + gdouble antiSeedsMax; /*gaussian height in msd of enthalpy in the generation among potential parents*/ + gdouble antiSeedsSigma; /*gaussian width in average distance in the generation among potential parents*/ +/*4.11 Space group*/ + gboolean doSpaceGroup; /*determine space group*/ + gdouble SymTolerance; /*precision (ang) in the symmetry determination*/ +/*4.12 Developers*/ + gint repeatForStatistics; /*repeat USPEX calculation rFS times*/ + gdouble stopFitness; /*set halting fitness condition*/ + gboolean collectForces; /*collect all relaxation information (from VASP)*/ +/*4.13 Seldom*/ + gboolean ordering_active; /*biasing of variation parameters*/ + gboolean symmetrize; /*all structures into std symmetrized crystallographic settings*/ + gint *valenceElectr; /*number of valence electrons for each atom type*/ + gdouble percSliceShift; /*probability of shifting slabs*/ + gint dynamicalBestHM; /*number of survivors will vary: 0:no 1:yes 2:yes, with max diversity*/ + gint *softMutOnly; /*generations that are produced by softmutation*/ + gdouble maxDistHeredity; /*max cos distances between structure involved in heredity*/ + gint manyParents; /*more than 2 slices (or parents) are used for heredity*/ + gdouble minSlice; /*minimal thickness (Ang) of a slice*/ + gdouble maxSlice; /*maximal thickness (Ang) of a slice*/ + gint numberParents; /*number of parents for cluster*/ +/*5 Additional*/ +/*5.1 molecular crystal*/ + /*no keyword in this section*/ +/*5.2 Surfaces*/ + gdouble thicknessS; /*thickness (Ang) of the surface (ie adatoms) surface region*/ + gdouble thicknessB; /*thickness (Ang) of the buffer (no adatoms) surface region*/ + gint reconstruct; /*max number of multiplication of the surface cell (for reconstruction)*/ +/*5.3 Variable composition*/ + gint firstGeneMax; /*how many different composition are sampled in the 1st generation*/ + gint minAt; /*minimum number of atoms/unit cell in the 1st generation*/ + gint maxAt; /*maximum number of atoms/unit cell in the 1st generation*/ + gdouble fracTrans; /*fraction of structures generated by transmutation*/ + gdouble howManyTrans; /*maximum fraction of atoms in the structure that are being transmuted*/ + gint *specificTrans; /*specific transmutations*/ +/*5.4 metadynamics*/ + gdouble GaussianWidth; /*width of each gaussian added to surface energy*/ + gdouble GaussianHeight; /*height of each gaussian added to surface energy*/ + gint FullRelax; /*whether relax within a fixed cell, fully relax best, or all structures*/ + gdouble maxVectorLength; /*maximum (Ang) unit cell length (if larger then steep force correction is added)*/ +/*5.5 Particle swarm optimization*/ + gdouble PSO_softMut; /*weight of softmutation*/ + gdouble PSO_BestStruct; /*weight of heredity with best position, within same PSO particle*/ + gdouble PSO_BestEver; /*weight of heredity with globally best PSO particle*/ +/*6 Phase Transition Pathways*/ +/*6.1 VC-NEB*/ + /*no keyword in this section*/ +/*6.2 VC-NEB options*/ + gint vcnebType; /*type of VC-NEB*/ + gint _vcnebtype_method; /*HIDDEN: X.. digit in vcnebType: use VCNEB or just relax*/ + gint _vcnebtype_img_num; /*HIDDEN: .X. digit in vcnebType: fixed or variable image number*/ + gint _vcnebtype_spring; /*HIDDEN: ..X digit in vcnebType: fixed or variable spring constant*/ + gint numImages; /*initial number of images*/ + gint numSteps; /*maximum VC-NEB steps*/ + gint optReadImages; /*reading the Image file (all image, initial and final, or +intermediate)*/ + gboolean optimizerType; /*optimization algorithm*/ + gint optRelaxType; /*relaxation mode (fixed cell, only cell, full relaxation)*/ + gdouble dt; /*time step*/ + gdouble ConvThreshold; /*halting RMS (eV/Ang) condition*/ + gdouble VarPathLenght; /*min distance (* 1.5) between 2 image to generate a new image*/ + gdouble K_min; /*min spring constant, for variable spring cte calculation*/ + gdouble K_max; /*max spring constant, for variable spring cte calculation*/ + gdouble Kconstant; /*spring constant, for variable spring cte calculation*/ + gboolean optFreezing; /*freeze image structure (when ConvThreshold is achieve)*/ + gint optMethodCIDI; /*use climbing image / downing image method*/ + gint startCIDIStep; /*CI/DI method starting step*/ + gint *pickupImages; /*# of images chosen for CI/DI*/ + gint FormatType; /*structure format in the output pathway (ONLY VASP5 is supported!)*/ + gint PrintStep; /*save VC-NEB restart files in STEP directory every PS steps*/ +/*6.3 Set initial pathway in VC-NEB*/ + /*no keyword in this section*/ + } uspex_calc_struct; /* execution structure */ typedef struct { @@ -80,6 +221,7 @@ typedef struct { gchar *job_path; } uspex_exec_struct; + /*methods of interest*/ diff --git a/src/gl_graph.c b/src/gl_graph.c index 4a93adc..3f64e0c 100644 --- a/src/gl_graph.c +++ b/src/gl_graph.c @@ -396,7 +396,7 @@ yy = (gint) yf; yy *= -1; yy += oy; if((y>yy-3)&&(yuspex; + uspex_output_struct *uspex_calc=model->uspex; /*we have a hit*/ graph->select=struct_sel; graph->select_2=ptr[i]; @@ -434,7 +434,7 @@ for (list=graph->set_list ; list ; list=g_slist_next(list)) yy *= -1; yy += oy; if((y>yy-3)&&(yuspex; + uspex_output_struct *uspex_calc=model->uspex; /*we have a hit*/ graph->select=struct_sel; graph->select_2=ptr[i]; diff --git a/src/gui_defs.h b/src/gui_defs.h index d1ad259..6f9974b 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -30,6 +30,11 @@ The GNU GPL can also be found at http://www.gnu.org /* DEFINES: interface */ #define GUI_SPACE 0 +#define GUI_OBJ GtkWidget +#define GUI_NOTE GtkNotebook +#define GUI_TEXTVIEW GtkTextView +#define GUI_TEXTVIEW_BUFFER GtkTextBuffer + /*****************/ /* BOX INTERFACE */ /*****************/ @@ -340,6 +345,10 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ /********************/ /*create a tooltip with text ("text") for the widget (widget).*/ #define GUI_TOOLTIP(widget,text) gtk_widget_set_tooltip_text(widget,text) +/*registering value of entry (entry) into variable (value), according to format (format).*/ +#define GUI_REG_VAL(entry,value,format) do{\ + sscanf(gtk_entry_get_text(GTK_ENTRY(entry)),format,&(value));\ +}while(0) /*set the entry (entry) text ("text")*/ #define GUI_ENTRY_TEXT(entry,text) gtk_entry_set_text(GTK_ENTRY(entry),text); /*connect entry (entry) on change with the function (function) passing data (data).*/ @@ -350,6 +359,8 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_ENTRY_GET_TEXT(entry,text) do{\ text=g_strdup(gtk_entry_get_text(GTK_ENTRY(entry)));\ }while(0) +/*get the lenght of text in entry (entry)*/ +#define GUI_ENTRY_LENGHT(entry) (gtk_entry_get_text_length(GTK_ENTRY(entry))) /*set sensitivity of a widget*/ #define GUI_LOCK(widget) gtk_widget_set_sensitive(widget,FALSE) #define GUI_UNLOCK(widget) gtk_widget_set_sensitive(widget,TRUE) diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 6d96788..5a450f8 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -76,8 +76,8 @@ void gui_vasp_init(){ /*********************************************************/ /* Load calculation setting from an included vasprun.xml */ /*********************************************************/ -void load_vasprun_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; +void load_vasprun_dialog(void){ + GUI_OBJ *file_chooser; gint have_answer; gchar *filename; gchar *text; @@ -100,8 +100,8 @@ void load_vasprun_dialog(void){//IGNORED: GtkButton *button, gpointer data /**************************/ /* load mpirun executable */ /**************************/ -void load_mpirun_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; +void load_mpirun_dialog(void){ + GUI_OBJ *file_chooser; gint have_answer; gchar *filename; gchar *text; @@ -123,8 +123,8 @@ void load_mpirun_dialog(void){//IGNORED: GtkButton *button, gpointer data /****************************/ /* load the vasp executable */ /****************************/ -void load_vasp_exe_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; +void load_vasp_exe_dialog(void){ + GUI_OBJ *file_chooser; gint have_answer; gchar *filename; gchar *text; @@ -146,8 +146,8 @@ void load_vasp_exe_dialog(void){//IGNORED: GtkButton *button, gpointer data /*****************************************/ /* point to the path to run the VASP job */ /*****************************************/ -void load_path_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; +void load_path_dialog(void){ + GUI_OBJ *file_chooser; gint have_answer; gchar *filename; gchar *text; @@ -653,7 +653,7 @@ void vasp_gui_refresh(){ /************************************************************/ /* Preload with default parameter from the simple interface */ /************************************************************/ -void vasp_apply_simple(void){//IGNORED: GtkButton *button, gpointer data +void vasp_apply_simple(void){ /*simple interface*/ gint calcul; gint system; @@ -893,7 +893,7 @@ void vasp_apply_simple(void){//IGNORED: GtkButton *button, gpointer data /******************/ /* selecting PREC */ /******************/ -void vasp_prec_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_prec_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch (index){ @@ -915,7 +915,7 @@ void vasp_prec_selected(GtkWidget *w){//IGNORED: struct model_pak *model /*****************************************/ /* Toggle use of automatic prec settings */ /*****************************************/ -void prec_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void prec_toggle(void){ gchar *text; if(!(vasp_gui.calc.use_prec)){ /*switch to manual values*/ @@ -937,7 +937,7 @@ void prec_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /******************/ /* selecting ALGO */ /******************/ -void vasp_algo_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_algo_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.ialgo); @@ -976,7 +976,7 @@ void vasp_algo_selected(GtkWidget *w){//IGNORED: struct model_pak *model /*******************/ /* selecting IALGO */ /*******************/ -void vasp_ialgo_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_ialgo_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1016,7 +1016,7 @@ void vasp_ialgo_selected(GtkWidget *w){//IGNORED: struct model_pak *model /***************/ /* elec toggle */ /***************/ -void elec_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void elec_toggle(void){ gchar *text; if(!(vasp_gui.calc.auto_elec)){ /*switch to manual values*/ @@ -1048,7 +1048,7 @@ void elec_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /*******************/ /* selecting LREAL */ /*******************/ -void vasp_lreal_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_lreal_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1066,7 +1066,7 @@ void vasp_lreal_selected(GtkWidget *w){//IGNORED: struct model_pak *model /***************/ /* grid toggle */ /***************/ -void grid_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void grid_toggle(void){ gchar *text; if(!(vasp_gui.calc.auto_grid)){ /*switch to manual values*/ @@ -1102,7 +1102,7 @@ void grid_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /***************************/ /* ismear value is changed */ /***************************/ -void ismear_changed(GtkWidget *w){//IGNORED: struct model_pak *model +void ismear_changed(GUI_OBJ *w){ gchar *label; GUI_ENTRY_GET_TEXT(w,label); sscanf(label,"%i",&(vasp_gui.calc.ismear)); @@ -1119,7 +1119,7 @@ void ismear_changed(GtkWidget *w){//IGNORED: struct model_pak *model /*****************************/ /* kspacing value is changed */ /*****************************/ -void kspacing_changed(GtkWidget *w){//IGNORED: struct model_pak *model +void kspacing_changed(GUI_OBJ *w){ gchar *label; GUI_ENTRY_GET_TEXT(w,label); sscanf(label,"%lf",&(vasp_gui.calc.kspacing)); @@ -1128,21 +1128,21 @@ void kspacing_changed(GtkWidget *w){//IGNORED: struct model_pak *model /************************/ /* toggle LNONCOLLINEAR */ /************************/ -void lnoncoll_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void lnoncoll_toggle(void){ /* unselecting LNONCOLLINEAR automatically unselect LSORBIT */ if(!vasp_gui.calc.non_collinear) GUI_TOGGLE_OFF(vasp_gui.lsorbit); } /******************/ /* toggle LSORBIT */ /******************/ -void lsorbit_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void lsorbit_toggle(void){ /* LSORBIT automatically select LNONCOLLINEAR */ if(vasp_gui.calc.lsorbit) GUI_TOGGLE_ON(vasp_gui.lnoncoll); } /*****************/ /* selecting GGA */ /*****************/ -void vasp_gga_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_gga_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1162,7 +1162,7 @@ void vasp_gga_selected(GtkWidget *w){//IGNORED: struct model_pak *model /*********************/ /* selecting METAGGA */ /*********************/ -void vasp_metagga_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_metagga_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.cmbj); @@ -1186,7 +1186,7 @@ void vasp_metagga_selected(GtkWidget *w){//IGNORED: struct model_pak *model /*******************/ /* toggle LMETAGGA */ /*******************/ -void metagga_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void metagga_toggle(void){ if(!vasp_gui.calc.lmetagga){ /*switch to manual values*/ GUI_LOCK(vasp_gui.metagga); @@ -1205,7 +1205,7 @@ void metagga_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /*******************/ /* toggle L(S)DA+U */ /*******************/ -void ldau_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void ldau_toggle(void){ gchar *text; if(!vasp_gui.calc.ldau){ /*switch to manual values*/ @@ -1244,7 +1244,7 @@ void ldau_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /***************************/ /* selecting L(S)DA+U type */ /***************************/ -void vasp_ldau_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_ldau_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1260,7 +1260,7 @@ void vasp_ldau_selected(GtkWidget *w){//IGNORED: struct model_pak *model /***************************************/ /* selecting L(S)DA+U output verbosity */ /***************************************/ -void vasp_ldau_print_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_ldau_print_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1276,7 +1276,7 @@ void vasp_ldau_print_selected(GtkWidget *w){//IGNORED: struct model_pak *model /************************************/ /* toggle manual selection of mixer */ /************************************/ -void mixer_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void mixer_toggle(void){ gchar *text; if((vasp_gui.calc.auto_mixer)){ /*switch to manual values*/ @@ -1323,7 +1323,7 @@ void mixer_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box /*******************/ /* selecting mixer */ /*******************/ -void vasp_mixer_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_mixer_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.wc); @@ -1347,7 +1347,7 @@ void vasp_mixer_selected(GtkWidget *w){//IGNORED: struct model_pak *model /***************************/ /* selecting initial mixer */ /***************************/ -void vasp_inimix_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_inimix_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1361,7 +1361,7 @@ void vasp_inimix_selected(GtkWidget *w){//IGNORED: struct model_pak *model /************************/ /* selecting pre-mixing */ /************************/ -void vasp_mixpre_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_mixpre_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1377,7 +1377,7 @@ void vasp_mixpre_selected(GtkWidget *w){//IGNORED: struct model_pak *model /********************/ /* selecting idipol */ /********************/ -void vasp_idipol_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_idipol_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); GUI_UNLOCK(vasp_gui.ldipol); @@ -1409,7 +1409,7 @@ void vasp_idipol_selected(GtkWidget *w){//IGNORED: struct model_pak *model /********************/ /* selecting lorbit */ /********************/ -void vasp_lorbit_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_lorbit_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch(index){ @@ -1433,7 +1433,7 @@ void vasp_lorbit_selected(GtkWidget *w){//IGNORED: struct model_pak *model /********************/ /* selecting ibrion */ /********************/ -void vasp_ibrion_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_ibrion_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); GUI_LOCK(vasp_gui.tebeg); @@ -1479,7 +1479,7 @@ void vasp_ibrion_selected(GtkWidget *w){//IGNORED: struct model_pak *model /******************/ /* selecting ISIF */ /******************/ -void vasp_isif_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_isif_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); vasp_gui.calc.isif=index; @@ -1521,7 +1521,7 @@ void vasp_isif_selected(GtkWidget *w){//IGNORED: struct model_pak *model /****************/ /* isif toggles */ /****************/ -void isif_toggle(void){//IGNORED: GtkWidget *w, GtkWidget *box +void isif_toggle(void){ /*recalculate isif function of the user switches*/ if((vasp_gui.rions)&&(!vasp_gui.rshape)&&(!vasp_gui.rvolume)) {if(vasp_gui.calc.isif>2) vasp_gui.calc.isif=2;} else if((vasp_gui.rions)&&(vasp_gui.rshape)&&(vasp_gui.rvolume)) vasp_gui.calc.isif=3; @@ -1561,7 +1561,7 @@ void toggle_poscar_sd(){ /*************************/ /* selecting poscar_free */ /*************************/ -void vasp_poscar_free_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_poscar_free_selected(GUI_OBJ *w){ gint index; gint ix; gchar *text; @@ -1683,7 +1683,7 @@ void toggle_poscar_direct(){ /*************************/ /* selecting poscar atom */ /*************************/ -void vasp_poscar_atoms_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_poscar_atoms_selected(GUI_OBJ *w){ gint index; gchar *text; gdouble x,y,z; @@ -1744,7 +1744,6 @@ void vasp_poscar_atoms_selected(GtkWidget *w){//IGNORED: struct model_pak *mode void vasp_atom_modified(){ gint index; gchar *text; - gchar *tamp; gchar tx,ty,tz; /*mini-sync*/ GUI_COMBOBOX_GET(vasp_gui.poscar_atoms,index);/*PUSH*/ @@ -1799,13 +1798,17 @@ void vasp_atom_delete(){ gint index; gchar *text; GUI_COMBOBOX_GET(vasp_gui.poscar_atoms,index); - if(index==-1) return;/*nothing selected anyway*/ + if(index==-1) { + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,0); + return;/*nothing selected anyway*/ + } GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); if(g_ascii_strcasecmp(text,"ADD atom") == 0) { g_free(text); return;/*can't delete this one*/ } GUI_COMBOBOX_DEL(vasp_gui.poscar_atoms,index); + if(index-1<0) index=1; GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,index-1); g_free(text); vasp_gui.poscar_dirty=TRUE; @@ -1813,7 +1816,7 @@ void vasp_atom_delete(){ /**************************/ /* selecting kpoints_mode */ /**************************/ -void vasp_kpoints_mode_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_kpoints_mode_selected(GUI_OBJ *w){ gint index; gchar *text; GUI_COMBOBOX_GET(w,index); @@ -1894,7 +1897,7 @@ void vasp_kpoints_mode_selected(GtkWidget *w){//IGNORED: struct model_pak *model /**********************/ /* selecting a kpoint */ /**********************/ -void vasp_kpoints_kpts_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_kpoints_kpts_selected(GUI_OBJ *w){ gint index; gchar *text; gdouble x,y,z,wt; @@ -1928,7 +1931,6 @@ void vasp_kpoints_kpts_selected(GtkWidget *w){//IGNORED: struct model_pak *model void vasp_kpoint_modified(){ gint index; gchar *text; - gchar *tamp; /*mini-sync*/ GUI_COMBOBOX_GET(vasp_gui.kpoints_kpts,index);/*PUSH*/ GUI_COMBOBOX_GET_TEXT(vasp_gui.kpoints_kpts,text); @@ -1979,7 +1981,10 @@ void vasp_kpoint_delete(){ gint index; gchar *text; GUI_COMBOBOX_GET(vasp_gui.kpoints_kpts,index); - if(index==-1) return;/*nothing selected anyway*/ + if(index==-1) { + GUI_COMBOBOX_SET(vasp_gui.kpoints_kpts,0); + return;/*nothing selected anyway*/ + } GUI_COMBOBOX_GET_TEXT(vasp_gui.kpoints_kpts,text); if(g_ascii_strcasecmp(text,"ADD kpoint") == 0) { g_free(text); @@ -1987,6 +1992,7 @@ void vasp_kpoint_delete(){ } g_free(text); GUI_COMBOBOX_DEL(vasp_gui.kpoints_kpts,index); + if(index-1<0) index=1; GUI_COMBOBOX_SET(vasp_gui.kpoints_kpts,index-1); } /****************/ @@ -2002,7 +2008,7 @@ void toogle_tetra(){ /*************************/ /* selecting tetrahedron */ /*************************/ -void vasp_tetra_selected(GtkWidget *w){//IGNORED: struct model_pak *model +void vasp_tetra_selected(GUI_OBJ *w){ gint index; gchar *text; gdouble wt; @@ -2035,7 +2041,6 @@ void vasp_tetra_selected(GtkWidget *w){//IGNORED: struct model_pak *model void vasp_tetra_modified(){ gint index; gchar *text; - gchar *tamp; /*mini-sync*/ GUI_COMBOBOX_GET(vasp_gui.tetra,index); GUI_COMBOBOX_GET_TEXT(vasp_gui.tetra,text); @@ -2071,7 +2076,7 @@ void vasp_tetra_delete(){ gint index; gchar *text; GUI_COMBOBOX_GET(vasp_gui.tetra,index); - if(index==-1) {/*TODO: set similar strategy to kpoints and atom lists*/ + if(index==-1) { GUI_COMBOBOX_SET(vasp_gui.tetra,0); return;/*nothing selected anyway*/ } @@ -2082,7 +2087,7 @@ void vasp_tetra_delete(){ } g_free(text); GUI_COMBOBOX_DEL(vasp_gui.tetra,index); - if(index-1<0) index=1;/*TODO: set similar strategy to kpoints and atom lists*/ + if(index-1<0) index=1; GUI_COMBOBOX_SET(vasp_gui.tetra,index-1); } /****************************************************/ @@ -2132,8 +2137,8 @@ void potcar_get_species(){ /************************************************************************/ /* point to a file where POTCAR information is stored for each elements */ /************************************************************************/ -void load_potcar_file_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; +void load_potcar_file_dialog(void){ + GUI_OBJ *file_chooser; gint have_answer; char *filename; gchar *text; @@ -2158,7 +2163,7 @@ void load_potcar_file_dialog(void){//IGNORED: GtkButton *button, gpointer data /*****************************************************/ /* register a specific pseudopotential for a species */ /*****************************************************/ -void apply_species_flavor(void){//IGNORED: GtkButton *button, gpointer data +void apply_species_flavor(void){ gchar *text; gchar *symbol; gchar *flavor; @@ -2272,6 +2277,7 @@ void potcar_folder_get_info(){ GUI_ENTRY_GET_TEXT(vasp_gui.potcar_folder,path); folders=file_dir_list(path,FALSE); g_free(path); + vasp_gui.poscar_dirty=TRUE;/*FIX _BUG_ when loading POTCAR folder *after* changing vasprun.xml*/ vasp_poscar_sync(); #if DEBUG_POTCAR_FOLDER fprintf(stdout,"#DBG: looking for %s\n",vasp_gui.calc.species_symbols); @@ -2319,8 +2325,8 @@ void potcar_folder_get_info(){ /***************************************************************/ /* point to a folder where POTCAR are stored for each elements */ /***************************************************************/ -void load_potcar_folder_dialog(void){//IGNORED: GtkButton *button, gpointer data - GtkWidget *file_chooser; +void load_potcar_folder_dialog(void){ + GUI_OBJ *file_chooser; gint have_answer; gchar *filename; gchar *text; @@ -2336,6 +2342,7 @@ void load_potcar_folder_dialog(void){//IGNORED: GtkButton *button, gpointer data if(vasp_gui.calc.potcar_folder!=NULL) g_free(vasp_gui.calc.potcar_folder); vasp_gui.calc.potcar_folder=g_strdup_printf("%s",filename); g_free (filename); + /*sync before*/ potcar_folder_get_info(); } } @@ -2344,7 +2351,7 @@ void load_potcar_folder_dialog(void){//IGNORED: GtkButton *button, gpointer data /*************************************/ /* Select POTCAR information by file */ /*************************************/ -void toggle_potcar_file(void){//IGNORED: GtkWidget *w, GtkWidget *box +void toggle_potcar_file(void){ vasp_gui.have_potcar_folder=FALSE; GUI_LOCK(vasp_gui.potcar_folder); GUI_LOCK(vasp_gui.potcar_folder_button); @@ -2356,7 +2363,7 @@ void toggle_potcar_file(void){//IGNORED: GtkWidget *w, GtkWidget *box /*************************************/ /* Select POTCAR information by path */ /*************************************/ -void toggle_potcar_folder(void){//IGNORED: GtkWidget *w, GtkWidget *box +void toggle_potcar_folder(void){ vasp_gui.have_potcar_folder=TRUE; GUI_LOCK(vasp_gui.potcar_file); GUI_LOCK(vasp_gui.potcar_file_button); @@ -2368,7 +2375,7 @@ void toggle_potcar_folder(void){//IGNORED: GtkWidget *w, GtkWidget *box /************************************************************************/ /* equilibrate NPAR,NCORE,KPAR with the number of CPUs */ /************************************************************************/ -void parallel_eq(void){//IGNORED: *GtkWidget *w, GtkWidget *box +void parallel_eq(void){ /*parallel equilibration*/ gint np,ncore,kpar; /* no need to sync */ @@ -2506,7 +2513,7 @@ void vasp_poscar_sync(){ /************************/ /* Switch notebook page */ /************************/ -void vasp_gui_page_switch(GtkNotebook *notebook,GtkWidget *page,guint page_num){//IGNORED: gpointer user_data +void vasp_gui_page_switch(GUI_NOTE *notebook,GUI_OBJ *page,guint page_num){ gint from_page; gchar *text; /* some (few) values need to be updated from a page to another*/ @@ -2565,7 +2572,6 @@ void vasp_gui_page_switch(GtkNotebook *notebook,GtkWidget *page,guint page_num){ /* convert current vasp_gui into current vasp_calc_struct */ /**********************************************************/ void vasp_gui_sync(){ - gchar *tamp; /* sync start here */ VASP_REG_TEXT(name); //prec already sync @@ -2982,7 +2988,7 @@ void vasp_cleanup(){ /*****************************************/ /* Execute or enqueue a vasp calculation */ /*****************************************/ -void run_vasp_exec(vasp_exec_struct *vasp_exec){//IGNORED: struct task_pak *task +void run_vasp_exec(vasp_exec_struct *vasp_exec){ /* Execute a vasp task TODO distant job */ gchar *cmd; gchar *cwd;/*for push/pull*/ @@ -3059,7 +3065,7 @@ void exec_calc(){ /********************************/ /* Quit vasp calculation dialog */ /********************************/ -void quit_vasp_gui(GtkWidget *w, gpointer data){ +void quit_vasp_gui(GUI_OBJ *w, gpointer data){ struct model_pak *model=data; vasp_cleanup(); dialog_destroy(w,model); @@ -3072,9 +3078,9 @@ void gui_vasp_dialog(void){ /*TODO: use distant connections*/ gchar *title; gpointer dialog; - GtkWidget *frame, *vbox, *hbox, *table; - GtkWidget *notebook, *page, *button, *label; - GtkWidget *separator; + GUI_OBJ *frame, *vbox, *hbox, *table; + GUI_OBJ *notebook, *page, *button, *label; + GUI_OBJ *separator; /* special */ GSList *list2; struct model_pak *data; diff --git a/src/gui_vasp.h b/src/gui_vasp.h index 321cc76..f1f5949 100644 --- a/src/gui_vasp.h +++ b/src/gui_vasp.h @@ -23,127 +23,13 @@ The GNU GPL can also be found at http://www.gnu.org /* simple VASP calcul interface */ /* DEFINES: sync vasp_gui and vasp_gui.calc */ #define VASP_REG_VAL(value,format) do{\ - tamp=g_strdup_printf("%s",gtk_entry_get_text(GTK_ENTRY(vasp_gui.value)));\ - sscanf(tamp,format,&(vasp_gui.calc.value));\ - g_free(tamp);\ + GUI_REG_VAL(vasp_gui.value,vasp_gui.calc.value,format);\ }while(0) #define VASP_REG_TEXT(value) do{\ -if(gtk_entry_get_text_length(GTK_ENTRY(vasp_gui.value))>0){\ - if(vasp_gui.calc.value!=NULL) g_free(vasp_gui.calc.value);\ - vasp_gui.calc.value=g_strdup_printf("%s",gtk_entry_get_text(GTK_ENTRY(vasp_gui.value)));\ -}else{\ - if(vasp_gui.calc.value!=NULL) g_free(vasp_gui.calc.value);\ - vasp_gui.calc.value=NULL;\ -}\ + if(vasp_gui.calc.value!=NULL) g_free(vasp_gui.calc.value);\ + if(GUI_ENTRY_LENGHT(vasp_gui.value)>0) GUI_ENTRY_GET_TEXT(vasp_gui.value,vasp_gui.calc.value);\ + else vasp_gui.calc.value=NULL;\ }while(0) -/* DEFINES: interface */ -#define _SPACE 0 -#define VASP_NEW_LINE() do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - gtk_container_set_border_width(GTK_CONTAINER(hbox), _SPACE);\ - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);\ -}while(0) -#define VASP_NEW_LABEL(text) do{\ - label = gtk_label_new(text);\ - gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);\ -}while(0) -#define VASP_TEXT_ENTRY(name,value,wilde) do{\ - name=gtk_entry_new();\ - if(value!=NULL) gtk_entry_set_text(GTK_ENTRY(name),g_strdup_printf("%s",value));\ - gtk_box_pack_start(GTK_BOX(hbox), name, wilde, wilde, 0);\ -}while(0) -#define VASP_ENTRY(name,value,format,size) do{\ - name=gtk_entry_new();\ - gtk_entry_set_text(GTK_ENTRY(name),g_strdup_printf(format,value));\ - gtk_entry_set_width_chars (GTK_ENTRY(name),size);\ - gtk_box_pack_start(GTK_BOX(hbox), name, FALSE, FALSE, 0);\ -}while(0) -#define VASP_NEW_SEPARATOR() do{\ - separator=gtk_hseparator_new();\ - gtk_box_pack_start(GTK_BOX(hbox), separator, TRUE, FALSE, 0);\ -}while(0) -#define VASP_REG_COMBO(name,default_text,function) do{\ - name = gtk_combo_new();\ - gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(name)->entry), FALSE);\ - gtk_combo_set_popdown_strings(GTK_COMBO(name), list);\ - g_list_free(list);\ - gtk_box_pack_start(GTK_BOX(hbox), name, FALSE, FALSE, 0);\ - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(name)->entry),default_text);\ - g_signal_connect(GTK_OBJECT(GTK_COMBO(name)->entry), "changed",GTK_SIGNAL_FUNC(function),data);\ -}while(0) -/* DEFINES: table interface */ -#define VASP_TEXT_TABLE(name,value,caption,l,r,t,b) do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - VASP_NEW_LABEL(caption);\ - VASP_TEXT_ENTRY(name,value,TRUE);\ - gtk_table_attach_defaults(GTK_TABLE(table),hbox,l,r,t,b);\ -}while(0) -#define VASP_ENTRY_TABLE(name,value,format,caption,l,r,t,b) do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - VASP_NEW_LABEL(caption);\ - VASP_NEW_SEPARATOR();\ - VASP_ENTRY(name,value,format,8);\ - gtk_table_attach_defaults(GTK_TABLE(table),hbox,l,r,t,b);\ -}while(0) -#define VASP_CHECK_TABLE(name,value,function,caption,l,r,t,b) do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - name = gui_direct_check(caption,&(value),function,NULL,hbox);\ - gtk_table_attach_defaults(GTK_TABLE(table),hbox,l,r,t,b);\ -}while(0) -#define VASP_COMBO_TABLE(name,default_text,function,caption,l,r,t,b) do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - VASP_NEW_LABEL(caption);\ - VASP_NEW_SEPARATOR();\ - VASP_REG_COMBO(name,default_text,function);\ - gtk_table_attach_defaults(GTK_TABLE(table),hbox,l,r,t,b);\ -}while(0) -#define VASP_SEPARATOR_TABLE(l,r,t,b) do{\ - separator=gtk_hseparator_new();\ - gtk_table_attach_defaults(GTK_TABLE(table),separator,l,r,t,b);\ -}while(0) -#define VASP_COMBOBOX_TABLE(name,caption,l,r,t,b) do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - label = gtk_label_new(caption);\ - gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);\ - name=gtk_combo_box_text_new_with_entry();\ - gtk_entry_set_editable(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(name))),FALSE);\ - gtk_box_pack_start(GTK_BOX(hbox),name,TRUE,TRUE,0);\ - gtk_table_attach_defaults(GTK_TABLE(table),hbox,l,r,t,b);\ -}while(0) -#define VASP_COMBOBOX_ADD(combobox,text) do{\ - gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combobox),text);\ -}while(0) -#define VASP_COMBOBOX_SETUP(combobox,default_value,function) do{\ - gtk_combo_box_set_active(GTK_COMBO_BOX(combobox),default_value);\ - g_signal_connect(GTK_COMBO_BOX_TEXT(combobox),"changed",GTK_SIGNAL_FUNC(function),data);\ -}while(0) -/*default spin is always [1,100]*/ -#define VASP_SPIN_TABLE(name,value,function,caption,l,r,t,b) do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - name = gui_direct_spin(caption,&(value),1.0,100.0,1.0,function,NULL,hbox);\ - gtk_table_attach_defaults(GTK_TABLE(table),hbox,l,r,t,b);\ -}while(0) -#define VASP_BUTTON_TABLE(name,type,function,l,r,t,b) do{\ - name=gtk_button_new_from_stock(type);\ - gtk_table_attach_defaults(GTK_TABLE(table),name,l,r,t,b);\ - g_signal_connect(GTK_OBJECT(name),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ -}while(0) -#define VASP_2BUTTONS_TABLE(name_1,name_2,function_1,function_2,l,r,t,b) do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - name_1 = gui_stock_button(GTK_STOCK_APPLY,function_1,NULL,hbox);\ - name_2 = gui_stock_button(GTK_STOCK_DELETE,function_2,NULL,hbox);\ - gtk_table_attach_defaults(GTK_TABLE(table),hbox,l,r,t,b);\ -}while(0) -/*left aligned labels*/ -#define VASP_LABEL_TABLE(caption,l,r,t,b) do{\ - hbox = gtk_hbox_new(FALSE, 0);\ - label = gtk_label_new(caption);\ - gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);\ - VASP_NEW_SEPARATOR();\ - gtk_table_attach_defaults(GTK_TABLE(table),hbox,l,r,t,b);\ -}while(0) -#define VASP_TOOLTIP(widget,text) gtk_widget_set_tooltip_text(widget,text) - /*page numbers*/ #define VASP_PAGE_SIMPLIFIED 0 #define VASP_PAGE_CONVERGENCE 1 @@ -153,207 +39,206 @@ if(gtk_entry_get_text_length(GTK_ENTRY(vasp_gui.value))>0){\ #define VASP_PAGE_KPOINTS 5 #define VASP_PAGE_POTCAR 6 #define VASP_PAGE_EXEC 7 - /* gui structure */ struct vasp_calc_gui{ /*just a recall*/ - GtkWidget *window; + GUI_OBJ *window; vasp_calc_struct calc; /*actual GUI*/ /*simple interface*/ - GtkWidget *simple_calcul; - GtkWidget *simple_system; + GUI_OBJ *simple_calcul; + GUI_OBJ *simple_system; gboolean simple_rgeom; - GtkWidget *simple_dim; + GUI_OBJ *simple_dim; gdouble dimension; - GtkWidget *simple_kgrid; - GtkWidget *simple_poscar; - GtkWidget *simple_species; - GtkWidget *simple_potcar; - GtkWidget *simple_potcar_button; - GtkWidget *simple_np; - GtkWidget *simple_ncore; - GtkWidget *simple_kpar; - GtkWidget *simple_apply; - GtkWidget *simple_message; - GtkTextBuffer *simple_message_buff; + GUI_OBJ *simple_kgrid; + GUI_OBJ *simple_poscar; + GUI_OBJ *simple_species; + GUI_OBJ *simple_potcar; + GUI_OBJ *simple_potcar_button; + GUI_OBJ *simple_np; + GUI_OBJ *simple_ncore; + GUI_OBJ *simple_kpar; + GUI_OBJ *simple_apply; + GUI_OBJ *simple_message; + GUI_TEXTVIEW_BUFFER *simple_message_buff; /*full interface*/ gint cur_page; - GtkWidget *name; - GtkWidget *file_entry; - GtkWidget *prec; - GtkWidget *encut; - GtkWidget *enaug; - GtkWidget *ediff; - GtkWidget *algo; - GtkWidget *ialgo; - GtkWidget *nsim; - GtkWidget *vtime; - GtkWidget *nbands; - GtkWidget *nelect; - GtkWidget *iwavpr; - GtkWidget *ismear; - GtkWidget *ismear_3;/*intentional duplicate*/ - GtkWidget *sigma; - GtkWidget *fermwe; - GtkWidget *fermdo; - GtkWidget *kgamma; - GtkWidget *kgamma_3;/*intentional duplicates*/ - GtkWidget *kspacing; - GtkWidget *kspacing_3;/*intentional duplicates*/ - GtkWidget *lreal; - GtkWidget *ropt; - GtkWidget *lmaxmix; - GtkWidget *lmaxpaw; - GtkWidget *istart; - GtkWidget *icharg; - GtkWidget *nupdown; - GtkWidget *magmom; - GtkWidget *lmaxtau; - GtkWidget *lnoncoll; - GtkWidget *saxis; - GtkWidget *gga; - GtkWidget *lsorbit; - GtkWidget *metagga; - GtkWidget *cmbj; - GtkWidget *cmbja; - GtkWidget *cmbjb; - GtkWidget *ldau; - GtkWidget *ldau_print; - GtkWidget *ldaul; - GtkWidget *ldauu; - GtkWidget *ldauj; + GUI_OBJ *name; + GUI_OBJ *file_entry; + GUI_OBJ *prec; + GUI_OBJ *encut; + GUI_OBJ *enaug; + GUI_OBJ *ediff; + GUI_OBJ *algo; + GUI_OBJ *ialgo; + GUI_OBJ *nsim; + GUI_OBJ *vtime; + GUI_OBJ *nbands; + GUI_OBJ *nelect; + GUI_OBJ *iwavpr; + GUI_OBJ *ismear; + GUI_OBJ *ismear_3;/*intentional duplicate*/ + GUI_OBJ *sigma; + GUI_OBJ *fermwe; + GUI_OBJ *fermdo; + GUI_OBJ *kgamma; + GUI_OBJ *kgamma_3;/*intentional duplicates*/ + GUI_OBJ *kspacing; + GUI_OBJ *kspacing_3;/*intentional duplicates*/ + GUI_OBJ *lreal; + GUI_OBJ *ropt; + GUI_OBJ *lmaxmix; + GUI_OBJ *lmaxpaw; + GUI_OBJ *istart; + GUI_OBJ *icharg; + GUI_OBJ *nupdown; + GUI_OBJ *magmom; + GUI_OBJ *lmaxtau; + GUI_OBJ *lnoncoll; + GUI_OBJ *saxis; + GUI_OBJ *gga; + GUI_OBJ *lsorbit; + GUI_OBJ *metagga; + GUI_OBJ *cmbj; + GUI_OBJ *cmbja; + GUI_OBJ *cmbjb; + GUI_OBJ *ldau; + GUI_OBJ *ldau_print; + GUI_OBJ *ldaul; + GUI_OBJ *ldauu; + GUI_OBJ *ldauj; /*mixer*/ - GtkWidget *nelm; - GtkWidget *nelmdl; - GtkWidget *nelmin; - GtkWidget *mixer; - GtkWidget *amix; - GtkWidget *bmix; - GtkWidget *amin; - GtkWidget *amix_mag; - GtkWidget *bmix_mag; - GtkWidget *maxmix; - GtkWidget *wc; - GtkWidget *inimix; - GtkWidget *mixpre; + GUI_OBJ *nelm; + GUI_OBJ *nelmdl; + GUI_OBJ *nelmin; + GUI_OBJ *mixer; + GUI_OBJ *amix; + GUI_OBJ *bmix; + GUI_OBJ *amin; + GUI_OBJ *amix_mag; + GUI_OBJ *bmix_mag; + GUI_OBJ *maxmix; + GUI_OBJ *wc; + GUI_OBJ *inimix; + GUI_OBJ *mixpre; /* dipol */ - GtkWidget *idipol; - GtkWidget *ldipol; - GtkWidget *lmono; - GtkWidget *dipol; - GtkWidget *epsilon; - GtkWidget *efield; + GUI_OBJ *idipol; + GUI_OBJ *ldipol; + GUI_OBJ *lmono; + GUI_OBJ *dipol; + GUI_OBJ *epsilon; + GUI_OBJ *efield; /* dos */ - GtkWidget *lorbit; - GtkWidget *have_paw; - GtkWidget *nedos; - GtkWidget *emin; - GtkWidget *emax; - GtkWidget *efermi; - GtkWidget *rwigs; + GUI_OBJ *lorbit; + GUI_OBJ *have_paw; + GUI_OBJ *nedos; + GUI_OBJ *emin; + GUI_OBJ *emax; + GUI_OBJ *efermi; + GUI_OBJ *rwigs; /* linear response */ - GtkWidget *loptics; - GtkWidget *lepsilon; - GtkWidget *lrpa; - GtkWidget *lnabla; - GtkWidget *lcalceps; - GtkWidget *cshift; + GUI_OBJ *loptics; + GUI_OBJ *lepsilon; + GUI_OBJ *lrpa; + GUI_OBJ *lnabla; + GUI_OBJ *lcalceps; + GUI_OBJ *cshift; /* grid */ - GtkWidget *ngx; - GtkWidget *ngy; - GtkWidget *ngz; - GtkWidget *ngxf; - GtkWidget *ngyf; - GtkWidget *ngzf; + GUI_OBJ *ngx; + GUI_OBJ *ngy; + GUI_OBJ *ngz; + GUI_OBJ *ngxf; + GUI_OBJ *ngyf; + GUI_OBJ *ngzf; /*ionic*/ - GtkWidget *nsw; - GtkWidget *ibrion; - GtkWidget *isif; - GtkWidget *relax_ions; - GtkWidget *relax_shape; - GtkWidget *relax_volume; - GtkWidget *ediffg; - GtkWidget *pstress; - GtkWidget *nfree; - GtkWidget *potim; + GUI_OBJ *nsw; + GUI_OBJ *ibrion; + GUI_OBJ *isif; + GUI_OBJ *relax_ions; + GUI_OBJ *relax_shape; + GUI_OBJ *relax_volume; + GUI_OBJ *ediffg; + GUI_OBJ *pstress; + GUI_OBJ *nfree; + GUI_OBJ *potim; /*md*/ - GtkWidget *tebeg; - GtkWidget *teend; - GtkWidget *smass; - GtkWidget *nblock; - GtkWidget *kblock; - GtkWidget *npaco; - GtkWidget *apaco; + GUI_OBJ *tebeg; + GUI_OBJ *teend; + GUI_OBJ *smass; + GUI_OBJ *nblock; + GUI_OBJ *kblock; + GUI_OBJ *npaco; + GUI_OBJ *apaco; /*symmetry*/ - GtkWidget *isym; - GtkWidget *sym_prec; + GUI_OBJ *isym; + GUI_OBJ *sym_prec; /* POSCAR */ - GtkWidget *poscar_free; - GtkWidget *poscar_direct; - GtkWidget *poscar_a0; - GtkWidget *poscar_ux; - GtkWidget *poscar_uy; - GtkWidget *poscar_uz; - GtkWidget *poscar_vx; - GtkWidget *poscar_vy; - GtkWidget *poscar_vz; - GtkWidget *poscar_wx; - GtkWidget *poscar_wy; - GtkWidget *poscar_wz; - GtkWidget *poscar_atoms; - GtkWidget *poscar_index; - GtkWidget *poscar_symbol; - GtkWidget *poscar_x; - GtkWidget *poscar_y; - GtkWidget *poscar_z; - GtkWidget *poscar_tx; - GtkWidget *poscar_ty; - GtkWidget *poscar_tz; + GUI_OBJ *poscar_free; + GUI_OBJ *poscar_direct; + GUI_OBJ *poscar_a0; + GUI_OBJ *poscar_ux; + GUI_OBJ *poscar_uy; + GUI_OBJ *poscar_uz; + GUI_OBJ *poscar_vx; + GUI_OBJ *poscar_vy; + GUI_OBJ *poscar_vz; + GUI_OBJ *poscar_wx; + GUI_OBJ *poscar_wy; + GUI_OBJ *poscar_wz; + GUI_OBJ *poscar_atoms; + GUI_OBJ *poscar_index; + GUI_OBJ *poscar_symbol; + GUI_OBJ *poscar_x; + GUI_OBJ *poscar_y; + GUI_OBJ *poscar_z; + GUI_OBJ *poscar_tx; + GUI_OBJ *poscar_ty; + GUI_OBJ *poscar_tz; /* KPOINTS */ - GtkWidget *kpoints_nkpts; - GtkWidget *kpoints_mode; - GtkWidget *kpoints_cart; - GtkWidget *kpoints_kx; - GtkWidget *kpoints_ky; - GtkWidget *kpoints_kz; - GtkWidget *kpoints_sx; - GtkWidget *kpoints_sy; - GtkWidget *kpoints_sz; - GtkWidget *kpoints_coord; - GtkWidget *have_tetra; - GtkWidget *kpoints_kpts; - GtkWidget *kpoints_i; - GtkWidget *kpoints_x; - GtkWidget *kpoints_y; - GtkWidget *kpoints_z; - GtkWidget *kpoints_w; - GtkWidget *kpoints_tetra; - GtkWidget *tetra; - GtkWidget *tetra_total; - GtkWidget *tetra_volume; - GtkWidget *tetra_i; - GtkWidget *tetra_w; - GtkWidget *tetra_a; - GtkWidget *tetra_b; - GtkWidget *tetra_c; - GtkWidget *tetra_d; + GUI_OBJ *kpoints_nkpts; + GUI_OBJ *kpoints_mode; + GUI_OBJ *kpoints_cart; + GUI_OBJ *kpoints_kx; + GUI_OBJ *kpoints_ky; + GUI_OBJ *kpoints_kz; + GUI_OBJ *kpoints_sx; + GUI_OBJ *kpoints_sy; + GUI_OBJ *kpoints_sz; + GUI_OBJ *kpoints_coord; + GUI_OBJ *have_tetra; + GUI_OBJ *kpoints_kpts; + GUI_OBJ *kpoints_i; + GUI_OBJ *kpoints_x; + GUI_OBJ *kpoints_y; + GUI_OBJ *kpoints_z; + GUI_OBJ *kpoints_w; + GUI_OBJ *kpoints_tetra; + GUI_OBJ *tetra; + GUI_OBJ *tetra_total; + GUI_OBJ *tetra_volume; + GUI_OBJ *tetra_i; + GUI_OBJ *tetra_w; + GUI_OBJ *tetra_a; + GUI_OBJ *tetra_b; + GUI_OBJ *tetra_c; + GUI_OBJ *tetra_d; /* POTCAR */ - GtkWidget *poscar_species; - GtkWidget *species_flavor; - GtkWidget *species_button; + GUI_OBJ *poscar_species; + GUI_OBJ *species_flavor; + GUI_OBJ *species_button; gboolean have_potcar_folder; - GtkWidget *potcar_select_file; - GtkWidget *potcar_file; - GtkWidget *potcar_file_button; - GtkWidget *potcar_select_folder; - GtkWidget *potcar_folder; - GtkWidget *potcar_folder_button; - GtkWidget *potcar_species; - GtkWidget *potcar_species_flavor; + GUI_OBJ *potcar_select_file; + GUI_OBJ *potcar_file; + GUI_OBJ *potcar_file_button; + GUI_OBJ *potcar_select_folder; + GUI_OBJ *potcar_folder; + GUI_OBJ *potcar_folder_button; + GUI_OBJ *potcar_species; + GUI_OBJ *potcar_species_flavor; /* PERF */ - GtkWidget *ncore; - GtkWidget *kpar; + GUI_OBJ *ncore; + GUI_OBJ *kpar; /*switches*/ gboolean have_xml; gboolean poscar_dirty; @@ -362,13 +247,13 @@ struct vasp_calc_gui{ gboolean rvolume; gboolean have_result; /* CALCUL */ - GtkWidget *job_vasp_exe;/*will be taken directly from gdis in the future*/ - GtkWidget *job_mpirun; - GtkWidget *job_path; - GtkWidget *job_nproc; + GUI_OBJ *job_vasp_exe;/*will be taken directly from gdis in the future*/ + GUI_OBJ *job_mpirun; + GUI_OBJ *job_path; + GUI_OBJ *job_nproc; /*buttons*/ - GtkWidget *button_save; - GtkWidget *button_exec; + GUI_OBJ *button_save; + GUI_OBJ *button_exec; }; /*methods of interest*/ From eabfe6f797f516d18e277d74c146d8a862d304b9 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 3 Aug 2018 20:03:52 +0900 Subject: [PATCH 15/56] gui_uspex: uspex parameters II --- src/file_uspex.c | 719 +++++++++++++++++++++++++++++++++++------------ src/file_uspex.h | 120 +++++--- 2 files changed, 616 insertions(+), 223 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 4b5a2d8..889e724 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -58,18 +58,18 @@ extern struct sysenv_pak sysenv; extern struct elem_pak elements[]; #define DEBUG_USPEX_READ 0 -#define _UC (*uspex_calc) +#define _UO (*uspex_output) gint read_parameter_uspex(gchar *filename, struct model_pak *model){ FILE *vf; gchar *line=NULL; gchar *ptr; gint idx; - uspex_output_struct *uspex_calc=model->uspex; + uspex_output_struct *uspex_output=model->uspex; /* specific */ gchar method; /*start*/ - _UC.nspecies=0; + _UO.nspecies=0; vf = fopen(filename, "rt"); if (!vf) return 1; line = file_read_line(vf); @@ -80,7 +80,7 @@ gint read_parameter_uspex(gchar *filename, struct model_pak *model){ case 'U': case 'u': /*uspex*/ - _UC.method=US_CM_USPEX; + _UO.method=US_CM_USPEX; property_add_ranked(2, "Calculation", "USPEX", model); #if DEBUG_USPEX_READ fprintf(stdout,"#DBG: USPEX calculationMethod=USPEX\n"); @@ -89,7 +89,7 @@ fprintf(stdout,"#DBG: USPEX calculationMethod=USPEX\n"); case 'M': case 'm': /*metadynamics*/ - _UC.method=US_CM_META; + _UO.method=US_CM_META; #if DEBUG_USPEX_READ fprintf(stdout,"#DBG: USPEX calculationMethod=META\n"); #endif @@ -97,7 +97,7 @@ fprintf(stdout,"#DBG: USPEX calculationMethod=META\n"); case 'V': case 'v': /*variable cell nudged elastic band*/ - _UC.method=US_CM_VCNEB; + _UO.method=US_CM_VCNEB; #if DEBUG_USPEX_READ fprintf(stdout,"#DBG: USPEX calculationMethod=VCNEB\n"); #endif @@ -105,7 +105,7 @@ fprintf(stdout,"#DBG: USPEX calculationMethod=VCNEB\n"); case 'P': case 'p': /*particle swarm optimization*/ - _UC.method=US_CM_PSO; + _UO.method=US_CM_PSO; #if DEBUG_USPEX_READ fprintf(stdout,"#DBG: USPEX calculationMethod=PSO\n"); #endif @@ -119,15 +119,15 @@ fprintf(stdout,"#DBG: USPEX calculationMethod=PSO\n"); } } if (find_in_string("calculationType",line) != NULL) { - sscanf(line,"%i : calculationType %*s",&(_UC.type)); + sscanf(line,"%i : calculationType %*s",&(_UO.type)); #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX calculationType=%i\n",_UC.type); +fprintf(stdout,"#DBG: USPEX calculationType=%i\n",_UO.type); #endif } if (find_in_string("optType",line) != NULL) { - sscanf(line,"%i : optType %*s",&(_UC.opt_type)); + sscanf(line,"%i : optType %*s",&(_UO.opt_type)); #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX optType=%i\n",_UC.type); +fprintf(stdout,"#DBG: USPEX optType=%i\n",_UO.type); #endif } @@ -137,25 +137,25 @@ fprintf(stdout,"#DBG: USPEX optType=%i\n",_UC.type); line = file_read_line(vf); ptr=&(line[0]); while(*ptr==' ') ptr++;/*skip initial space (if any)*/ - _UC.nspecies=1;/*there is at lease one species*/ + _UO.nspecies=1;/*there is at least one species*/ while(*ptr!='\0'){ if(*ptr==' ') { - _UC.nspecies++;ptr++; + _UO.nspecies++;ptr++; while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ }else ptr++; } #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX number_of_species=%i\n",_UC.nspecies); +fprintf(stdout,"#DBG: USPEX number_of_species=%i\n",_UO.nspecies); #endif /*now let's find each species symbol*/ - _UC.spe_Z=g_malloc(_UC.nspecies*sizeof(gint)); + _UO.spe_Z=g_malloc(_UO.nspecies*sizeof(gint)); ptr=&(line[0]);idx=0; while(*ptr==' ') ptr++;/*skip initial space (if any)*/ while((*ptr!='\n')&&(*ptr!='\0')){ if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - if(g_ascii_isdigit(*ptr)) _UC.spe_Z[idx]=g_ascii_strtod(ptr,NULL);/*user provided Z number*/ - else _UC.spe_Z[idx]=elem_symbol_test(ptr);/*user provided symbol*/ - if((_UC.spe_Z[idx]<=0)||(_UC.spe_Z[idx]>MAX_ELEMENTS-1)){/*X not allowed*/ + if(g_ascii_isdigit(*ptr)) _UO.spe_Z[idx]=g_ascii_strtod(ptr,NULL);/*user provided Z number*/ + else _UO.spe_Z[idx]=elem_symbol_test(ptr);/*user provided symbol*/ + if((_UO.spe_Z[idx]<=0)||(_UO.spe_Z[idx]>MAX_ELEMENTS-1)){/*X not allowed*/ g_free(line); line = g_strdup_printf("ERROR: USPEX Parameters.txt file contain invalid atom definition!\n"); gui_text_show(ERROR, line); @@ -163,7 +163,7 @@ fprintf(stdout,"#DBG: USPEX number_of_species=%i\n",_UC.nspecies); return -1; } #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX species[%i] Z=%i\n",idx,_UC.spe_Z[idx]); +fprintf(stdout,"#DBG: USPEX species[%i] Z=%i\n",idx,_UO.spe_Z[idx]); #endif ptr++;idx++; while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ @@ -179,13 +179,376 @@ fprintf(stdout,"#DBG: USPEX species[%i] Z=%i\n",idx,_UC.spe_Z[idx]); /*end of Parameters.txt read*/ return 0; } +/************************************************************************/ +/* Read Parameters.txt and fill keywords of uspex_calc_struct structure */ +/*For reading Parameters.txt files, *not* preparing a model for display.*/ +/************************************************************************/ +gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ +#define CALC (*calc) + FILE *vf; + long int vfpos; + gchar *line=NULL; + gchar *ptr; +// gchar tmp[64]; + gchar c; + gint i,j,k; +// gdouble d; + /*tests*/ + if(filename==NULL) return -1; + if(calc==NULL) return -1; + vf = fopen(filename, "rt"); + if (!vf) return -2; + /**/ + CALC._nspecies=0;/*set hidden to 0*/ +/*some lazy defines*/ +#define __NSPECIES(line) do{\ + if(CALC._nspecies==0){\ + ptr=&(line[0]);\ + while(*ptr==' ') ptr++;\ + CALC._nspecies=1;\ + while(*ptr!='\0'){\ + if(*ptr==' ') {\ + CALC._nspecies++;ptr++;\ + while(g_ascii_isgraph(*ptr)) ptr++;\ + }else ptr++;\ + }\ + }\ +}while(0) +#define __Q(a) #a + +#define __GET_BOOL(value) if (find_in_string(__Q(value),line)!=NULL){\ + k=0;sscanf(line,"%i%*s",&(k));\ + CALC.value=(k==1);\ + g_free(line);line = file_read_line(vf);\ + continue;\ +} +#define __GET_INT(value) if (find_in_string(__Q(value),line) != NULL) {\ + sscanf(line,"%i%*s",&(CALC.value));\ + g_free(line);line = file_read_line(vf);\ + continue;\ +} +#define __GET_DOUBLE(value) if (find_in_string(__Q(value),line) != NULL) {\ + sscanf(line,"%lf%*s",&(CALC.value));\ + g_free(line);line = file_read_line(vf);\ + continue;\ +} +#define __GET_STRING(value) if (find_in_string(__Q(value),line) != NULL) {\ + g_free(line);line = file_read_line(vf);\ + CALC.value=g_strdup(line);\ + g_free(line);line = file_read_line(vf);\ + g_free(line);line = file_read_line(vf);\ + continue;\ +} + line = file_read_line(vf); + while (line){ + if (find_in_string("calculationMethod",line) != NULL) { + c='\0';sscanf(line,"%c%*s",&(c)); + switch(c){ + case 'u': + case 'U':/*USPEX method*/ + CALC.calculationMethod=US_CM_USPEX; + break; + case 'm': + case 'M': + CALC.calculationMethod=US_CM_META; + break; + case 'v': + case 'V': + CALC.calculationMethod=US_CM_VCNEB; + break; + case 'p': + case 'P': + /*PSO method is not supported yet*/ + CALC.calculationMethod=US_CM_PSO; + break; + default: + CALC.calculationMethod=US_CM_UNKNOWN; + } + g_free(line); + line = file_read_line(vf); + continue; + } + if (find_in_string("calculationType",line) != NULL) { + k=0;sscanf(line,"%i%*s",&(k)); + j=k; + i=((int)(j/100))%10; + if((i<0)||(i>3)) { + g_free(line); + line = file_read_line(vf); + continue; + } + CALC._calctype_dim=i; + j-=i*100; + i=((int)(j/10))%10; + if((i<0)||(i>1)){ + g_free(line); + line = file_read_line(vf); + continue; + } + CALC._calctype_mol=(i==1); + j-=i*10; + i=j%10; + if((i<0)||(i>1)){ + g_free(line); + line = file_read_line(vf); + continue; + } + CALC._calctype_var=(i==1); + CALC.calculationType=k; + g_free(line); + line = file_read_line(vf); + continue; + } + if (find_in_string("optType",line) != NULL) { + k=0;sscanf(line,"%i%*s",&(k)); + switch (k){ + case 1: + CALC.optType=US_OT_ENTHALPY; + break; + case 2: + CALC.optType=US_OT_VOLUME; + break; + case 3: + CALC.optType=US_OT_HARDNESS; + break; + case 4: + CALC.optType=US_OT_ORDER; + break; + case 5: + CALC.optType=US_OT_DISTANCE; + break; + case 6: + CALC.optType=US_OT_DIELEC_S; + break; + case 7: + CALC.optType=US_OT_GAP; + break; + case 8: + CALC.optType=US_OT_DIELEC_GAP; + break; + case 9: + CALC.optType=US_OT_MAG; + break; + case 10: + CALC.optType=US_OT_QE; + break; + case 1101: + CALC.optType=US_OT_BULK_M; + break; + case 1102: + CALC.optType=US_OT_SHEAR_M; + break; + case 1103: + CALC.optType=US_OT_YOUNG_M; + break; + case 1104: + CALC.optType=US_OT_POISSON; + break; + case 1105: + CALC.optType=US_OT_PUGH_R; + break; + case 1106: + CALC.optType=US_OT_VICKERS_H; + break; + case 1107: + CALC.optType=US_OT_FRACTURE; + break; + case 1108: + CALC.optType=US_OT_DEBYE_T; + break; + case 1109: + CALC.optType=US_OT_SOUND_V; + break; + case 1110: + CALC.optType=US_OT_SWAVE_V; + break; + case 1111: + CALC.optType=US_OT_PWAVE_V; + break; + default: + CALC.optType=US_OT_UNKNOWN; + } + g_free(line); + line = file_read_line(vf); + continue; + } + if (find_in_string("atomType",line) !=NULL){ + g_free(line);line = file_read_line(vf);/*go next line*/ + /*if no _nspecies, get it now*/ + __NSPECIES(line); + /*look for atomType*/ + CALC.atomType = g_malloc(CALC._nspecies*sizeof(gint)); + for(i=0;iMAX_ELEMENTS-1)){/*invalid Z*/ + CALC.atomType[i]=0;/*allow it for now*/ + } + ptr++;i++; + while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ + } + g_free(line); + line = file_read_line(vf);/*this is the EndAtomType line*/ + g_free(line); + line = file_read_line(vf); + continue; + } + if (find_in_string("numSpecies",line) != NULL) { + vfpos=ftell(vf);/* flag */ + g_free(line);line = file_read_line(vf);/*go next line*/ + /*if no _nspecies, get it now*/ + __NSPECIES(line); + /*look for numSpecies*/ + /*1st get the total number of lines*/ + CALC._var_nspecies=0; + do{ + g_free(line);line = file_read_line(vf);/*go next line*/ + CALC._var_nspecies++; + }while(find_in_string("umSpecies",line) == NULL); + fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + line = file_read_line(vf);/*first line of numSpecies*/ + CALC.numSpecies = g_malloc(CALC._nspecies*CALC._var_nspecies*sizeof(gint)); + for(i=0;iuspex; + uspex_output_struct *uspex_output=model->uspex; /* specific */ gint idx=0; gchar *ptr; @@ -199,8 +562,8 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ /*Have fitness? Better watch for each case...*/ /*^^^^ I thought that calculationMethod = USPEX => fitness, but got defeated by EX19*/ line = file_read_line(vf); - if (find_in_string("Fitness",line) != NULL) _UC.have_fitness=TRUE; - else _UC.have_fitness=FALSE; + if (find_in_string("Fitness",line) != NULL) _UO.have_fitness=TRUE; + else _UO.have_fitness=FALSE; rewind(vf); /* deal with the problematic units */ if(fetch_in_file(vf,"eV/atom")!=0) e_red=TRUE; @@ -223,50 +586,50 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ /* META calculation have a gen=0 Individual unfortunately, it is *not* in the gather- -POSCARS file, so we ignore gen=0 for now. */ - if(_UC.method==US_CM_META){ + if(_UO.method==US_CM_META){ g_free(line); line = file_read_line(vf); vfpos=ftell(vf);/* flag */ } /*do a 1st pass to count stuctures*/ - _UC.num_struct=0; + _UO.num_struct=0; while (line){ - _UC.num_struct++; + _UO.num_struct++; sscanf(line," %*i %i %*s",&idx); if(idx>max_struct) max_struct=idx; g_free(line); line = file_read_line(vf); } - _UC.num_struct--; + _UO.num_struct--; fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ line = file_read_line(vf); /* now prepare arrays <- JOB=USPEX/300 example */ - if(_UC.num_struct==0) return 1; - _UC.red_index=g_malloc(max_struct*sizeof(gint)); - for(idx=0;idx_UC.num_gen) _UC.num_gen=_UC.ind[idx].gen; - _UC.red_index[red_index]=idx; - if(!e_red) _UC.ind[idx].E=_UC.ind[idx].energy/_UC.ind[idx].natoms; - else _UC.ind[idx].E=_UC.ind[idx].energy; + &(_UO.ind[idx].gen),&(red_index),&(tmp[0]),&(_UO.ind[idx].energy),&(_UO.ind[idx].volume)); + if(_UO.ind[idx].gen<_UO.num_gen) _UO.ind[idx].gen++; + if(_UO.ind[idx].gen>_UO.num_gen) _UO.num_gen=_UO.ind[idx].gen; + _UO.red_index[red_index]=idx; + if(!e_red) _UO.ind[idx].E=_UO.ind[idx].energy/_UO.ind[idx].natoms; + else _UO.ind[idx].E=_UO.ind[idx].energy; #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX[Individual]: GEN=%i STRUCT=%i e=%lf n_atom=%i E=%lf\n",_UC.ind[idx].gen,idx+1,_UC.ind[idx].energy,_UC.ind[idx].natoms,_UC.ind[idx].E); +fprintf(stdout,"#DBG: USPEX[Individual]: GEN=%i STRUCT=%i e=%lf n_atom=%i E=%lf\n",_UO.ind[idx].gen,idx+1,_UO.ind[idx].energy,_UO.ind[idx].natoms,_UO.ind[idx].E); #endif - if(_UC.ind[idx].E<_UC.min_E) _UC.min_E=_UC.ind[idx].E; - if(_UC.ind[idx].E>_UC.max_E) _UC.max_E=_UC.ind[idx].E; + if(_UO.ind[idx].E<_UO.min_E) _UO.min_E=_UO.ind[idx].E; + if(_UO.ind[idx].E>_UO.max_E) _UO.max_E=_UO.ind[idx].E; g_free(line); line = file_read_line(vf); idx++; @@ -306,7 +669,7 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ gdouble min_F=0.; gdouble max_E; gchar *atoms; - uspex_output_struct *uspex_calc; + uspex_output_struct *uspex_output; /* checks */ g_return_val_if_fail(model != NULL, 1); g_return_val_if_fail(filename != NULL, 2); @@ -319,7 +682,7 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ /*allocs*/ if(model->uspex!=NULL) g_free(model->uspex); model->uspex=g_malloc(sizeof(uspex_output_struct)); - uspex_calc=model->uspex; + uspex_output=model->uspex; /* TODO: check that selected file is OUTPUT.txt */ vf = fopen(filename, "rt"); if (!vf) return 1; @@ -347,10 +710,10 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ while(line) { if (find_in_string("Version",line) != NULL){ sscanf(line,"| Version %i.%i.%i %*s",&(max),&(med),&(min)); - _UC.version=min+10*med+100*max; - if(_UC.version!=944){ + _UO.version=min+10*med+100*max; + if(_UO.version!=944){ g_free(line); - line = g_strdup_printf("WARNING: USPEX version %i unsupported!\n",_UC.version); + line = g_strdup_printf("WARNING: USPEX version %i unsupported!\n",_UO.version); gui_text_show(WARNING, line); } @@ -387,7 +750,7 @@ if(job>-1){ case 1: case 2: case 3: - _UC.dim=ix; + _UO.dim=ix; break; default: line = g_strdup_printf("ERROR: reading USPEX OUTPUT.txt file!\n"); @@ -401,8 +764,8 @@ if(job>-1){ line = file_read_line(vf); sscanf(line," Molecular : %i %*s",&(ix)); job+=(ix*10); - if(ix==0) _UC.mol=FALSE; - else if(ix==1) _UC.mol=TRUE; + if(ix==0) _UO.mol=FALSE; + else if(ix==1) _UO.mol=TRUE; else{ line = g_strdup_printf("ERROR: reading USPEX OUTPUT.txt file!\n"); gui_text_show(ERROR, line); @@ -414,8 +777,8 @@ if(job>-1){ line = file_read_line(vf); sscanf(line," Variable Composition : %i %*s",&(ix)); job+=ix; - if(ix==0) _UC.var=FALSE; - else if(ix==1) _UC.var=TRUE; + if(ix==0) _UO.var=FALSE; + else if(ix==1) _UO.var=TRUE; else{ line = g_strdup_printf("ERROR: reading USPEX OUTPUT.txt file!\n"); gui_text_show(ERROR, line); @@ -449,24 +812,24 @@ if(job>-1){ goto uspex_fail; } /* --- CHECK type from Parameters.txt matches that of OUTPUT.TXT */ - if((job!=-1)&&(job!=_UC.type)){ + if((job!=-1)&&(job!=_UO.type)){ /*since VCNEB will fail here due to a non-unified OUTPUT.txt format *we need to be a little more permissive... */ - line = g_strdup_printf("ERROR: inconsistent USPEX files (%i!=%i)!\n",job,_UC.type); + line = g_strdup_printf("ERROR: inconsistent USPEX files (%i!=%i)!\n",job,_UO.type); gui_text_show(ERROR, line); g_free(line); goto uspex_fail; } g_free(aux_file); /*special case: no nspecies information*/ - if(_UC.nspecies==0) _UC.nspecies=num; -if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ + if(_UO.nspecies==0) _UO.nspecies=num; +if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ /* --- if calculationMethod={USPEX,META} */ model->basename=g_strdup_printf("uspex"); /* we have to open structure file first because of inconsistency in atom reporting in Individuals file*/ /* --- READ gatheredPOSCARS <- this is going to be the main model file */ /* ^^^ META: If gatheredPOSCARS_relaxed exists, read it instead */ - if(_UC.method==US_CM_META) { + if(_UO.method==US_CM_META) { aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); @@ -476,17 +839,17 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ } vf = fopen(aux_file, "rt"); if (!vf) { - if(_UC.ind!=NULL) g_free(_UC.ind); + if(_UO.ind!=NULL) g_free(_UO.ind); line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS file!\n"); gui_text_show(ERROR, line); g_free(line); goto uspex_fail; } /*count number of structures*/ - _UC.num_struct=0; + _UO.num_struct=0; line = file_read_line(vf); while(!feof(vf)){ - if((line[0]=='E')&&(line[1]=='A')) _UC.num_struct++; + if((line[0]=='E')&&(line[1]=='A')) _UO.num_struct++; g_free(line); line = file_read_line(vf); } @@ -494,7 +857,7 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ model->num_frames=0; vfpos=ftell(vf);/* flag */ line = file_read_line(vf); - _UC.ind=g_malloc((_UC.num_struct)*sizeof(uspex_individual)); + _UO.ind=g_malloc((_UO.num_struct)*sizeof(uspex_individual)); idx=0;ix=-1; while(!feof(vf)){ if((line[0]=='E')&&(line[1]=='A')) { @@ -506,9 +869,9 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ line = file_read_line(vf); } if(idx==5){/*calculate number of species and atoms*/ - _UC.ind[ix].atoms=g_malloc(_UC.nspecies*sizeof(gint)); - for(jdx=0;jdx<_UC.nspecies;jdx++) _UC.ind[ix].atoms[jdx]=0;/*init atoms*/ - _UC.ind[ix].natoms=0; + _UO.ind[ix].atoms=g_malloc(_UO.nspecies*sizeof(gint)); + for(jdx=0;jdx<_UO.nspecies;jdx++) _UO.ind[ix].atoms[jdx]=0;/*init atoms*/ + _UO.ind[ix].natoms=0; /*get this structure nspecies*/ ptr=&(line[0]); while(*ptr==' ') ptr++;/*skip initial space (if any)*/ @@ -519,7 +882,7 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ while(*ptr==' ') ptr++;/*skip space*/ }else ptr++; } - if(jdx<_UC.nspecies){ + if(jdx<_UO.nspecies){ gchar *line2;/*double buffer*/ /*we need to know which species is here*/ line2 = file_read_line(vf); @@ -532,9 +895,9 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ while((*ptr!='\0')&&(*ptr2!='\0')){ /*get the correct jdx number*/ jdx=0;/*we reset jdx to cope with 'OUT OF ORDER' poscar species, if any*/ - while((jdx<_UC.nspecies)&&(_UC.spe_Z[jdx]!=elem_symbol_test(ptr))) jdx++; - _UC.ind[ix].atoms[jdx]=g_ascii_strtod(ptr2,NULL); - _UC.ind[ix].natoms+=_UC.ind[ix].atoms[jdx]; + while((jdx<_UO.nspecies)&&(_UO.spe_Z[jdx]!=elem_symbol_test(ptr))) jdx++; + _UO.ind[ix].atoms[jdx]=g_ascii_strtod(ptr2,NULL); + _UO.ind[ix].natoms+=_UO.ind[ix].atoms[jdx]; ptr++;ptr2++; while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ while(g_ascii_isgraph(*ptr2)) ptr2++;/*go to next space/end*/ @@ -552,8 +915,8 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ ptr=&(line[0]); ptr2=ptr;jdx=0; do{/*get the number of each species (in the Parameters.txt order)*/ - _UC.ind[ix].atoms[jdx]=g_ascii_strtod(ptr,&ptr2); - _UC.ind[ix].natoms+=_UC.ind[ix].atoms[jdx]; + _UO.ind[ix].atoms[jdx]=g_ascii_strtod(ptr,&ptr2); + _UO.ind[ix].natoms+=_UO.ind[ix].atoms[jdx]; if(ptr2==ptr) break; jdx++; ptr=ptr2; @@ -570,7 +933,7 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ /* --- READ Individuals <- information about all structures */ /* ^^^ META: If Individuals_relaxed exists, read it instead */ - if(_UC.method==US_CM_META) { + if(_UO.method==US_CM_META) { aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); @@ -586,7 +949,7 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ } g_free(aux_file); /* --- open the last frame */ - if(_UC.method==US_CM_META) { + if(_UO.method==US_CM_META) { aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); @@ -596,7 +959,7 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ } vf = fopen(aux_file, "rt"); if (!vf) {/*very unlikely, we just opened it*/ - if(_UC.ind!=NULL) g_free(_UC.ind); + if(_UO.ind!=NULL) g_free(_UO.ind); line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS file!\n"); gui_text_show(ERROR, line); g_free(line); @@ -607,32 +970,32 @@ if((_UC.method==US_CM_USPEX)||(_UC.method==US_CM_META)){ /* --- Prepare the summary graph */ /*no need to load BESTIndividuals since we already know everything from Individuals*/ - _UC.graph=graph_new("ALL", model); - _UC.graph_best=graph_new("BEST", model); - if(_UC.num_struct>_UC.num_gen){ + _UO.graph=graph_new("ALL", model); + _UO.graph_best=graph_new("BEST", model); + if(_UO.num_struct>_UO.num_gen){ skip=0; gen=1; - _UC.num_best=_UC.num_gen; - _UC.best_ind=g_malloc((1+_UC.num_best)*sizeof(gint)); - _UC.best_ind[0]=0; + _UO.num_best=_UO.num_gen; + _UO.best_ind=g_malloc((1+_UO.num_best)*sizeof(gint)); + _UO.best_ind[0]=0; ix=0; - while(gen<=_UC.num_gen){ - while(_UC.ind[ix].genmax_E) max_E=_UC.ind[_UC.best_ind[gen+1]].E; - if(_UC.ind[_UC.best_ind[gen+1]].Emax_E) max_E=_UO.ind[_UO.best_ind[gen+1]].E; + if(_UO.ind[_UO.best_ind[gen+1]].E15) ix=5; - else ix=_UC.num_gen+1; - graph_set_xticks(TRUE,ix,_UC.graph); - graph_set_yticks(TRUE,5,_UC.graph); - graph_set_xticks(TRUE,ix,_UC.graph_best); - graph_set_yticks(TRUE,5,_UC.graph_best); + if(_UO.num_gen>15) ix=5; + else ix=_UO.num_gen+1; + graph_set_xticks(TRUE,ix,_UO.graph); + graph_set_yticks(TRUE,5,_UO.graph); + graph_set_xticks(TRUE,ix,_UO.graph_best); + graph_set_yticks(TRUE,5,_UO.graph_best); /* --- variable composition */ -if(_UC.var){ +if(_UO.var){ /* --- NEW: add a simple composition % graph for each species */ -if(_UC.nspecies>1){ +if(_UO.nspecies>1){ n_compo=2; ix=0; -for(species_index=0;species_index<_UC.nspecies;species_index++){ +for(species_index=0;species_index<_UO.nspecies;species_index++){ c=g_malloc(2*sizeof(gdouble));/*suppose at least 2 different compositions*/ - c[0]=(gdouble)_UC.ind[0].atoms[species_index] / (gdouble)_UC.ind[0].natoms; + c[0]=(gdouble)_UO.ind[0].atoms[species_index] / (gdouble)_UO.ind[0].natoms; c[1]=c[0]; compo=c[0]; ix=0; - while((compo==c[0])&&(ix<_UC.num_struct)){ - compo=(gdouble)_UC.ind[ix].atoms[species_index] / (gdouble)_UC.ind[ix].natoms; + while((compo==c[0])&&(ix<_UO.num_struct)){ + compo=(gdouble)_UO.ind[ix].atoms[species_index] / (gdouble)_UO.ind[ix].natoms; if(compo!=c[0]){ if(compo>c[0]) c[1]=compo; else { @@ -702,8 +1065,8 @@ for(species_index=0;species_index<_UC.nspecies;species_index++){ ix++; } if(c[1]==c[0]) continue;/*in VARCOMP calculation, one species can be kept fixed*/ - for(ix=0;ix<_UC.num_struct;ix++){ - compo=(gdouble)_UC.ind[ix].atoms[species_index] / (gdouble)_UC.ind[ix].natoms; + for(ix=0;ix<_UO.num_struct;ix++){ + compo=(gdouble)_UO.ind[ix].atoms[species_index] / (gdouble)_UO.ind[ix].natoms; if(compomax_E) max_E=e[jdx]; } @@ -757,21 +1120,21 @@ for(species_index=0;species_index<_UC.nspecies;species_index++){ } } /* prepare composition diagram*/ - line=g_strdup_printf("COMP_%s",elements[_UC.spe_Z[species_index]].symbol); - _UC.graph_comp=graph_new(line, model); + line=g_strdup_printf("COMP_%s",elements[_UO.spe_Z[species_index]].symbol); + _UO.graph_comp=graph_new(line, model); graph_add_borned_data( - n_compo,tag,0,1,_UC.min_E-(max_E-_UC.min_E)*0.05,max_E+(max_E-_UC.min_E)*0.05,GRAPH_USPEX_2D,_UC.graph_comp); + n_compo,tag,0,1,_UO.min_E-(max_E-_UO.min_E)*0.05,max_E+(max_E-_UO.min_E)*0.05,GRAPH_USPEX_2D,_UO.graph_comp); graph_add_borned_data( - n_compo,c,0,1,_UC.min_E-(max_E-_UC.min_E)*0.05,max_E+(max_E-_UC.min_E)*0.05,GRAPH_USPEX_2D,_UC.graph_comp); + n_compo,c,0,1,_UO.min_E-(max_E-_UO.min_E)*0.05,max_E+(max_E-_UO.min_E)*0.05,GRAPH_USPEX_2D,_UO.graph_comp); graph_add_borned_data( - n_compo,e,0,1,_UC.min_E-(max_E-_UC.min_E)*0.05,max_E+(max_E-_UC.min_E)*0.05,GRAPH_USPEX_2D,_UC.graph_comp); + n_compo,e,0,1,_UO.min_E-(max_E-_UO.min_E)*0.05,max_E+(max_E-_UO.min_E)*0.05,GRAPH_USPEX_2D,_UO.graph_comp); g_free(line); g_free(tag); g_free(c); g_free(e); /*set ticks*/ - graph_set_xticks(TRUE,3,_UC.graph_comp); - graph_set_yticks(TRUE,5,_UC.graph_comp); + graph_set_xticks(TRUE,3,_UO.graph_comp); + graph_set_yticks(TRUE,5,_UO.graph_comp); } @@ -786,14 +1149,14 @@ for(species_index=0;species_index<_UC.nspecies;species_index++){ model_prep(model); -}else if(_UC.method==US_CM_VCNEB){ +}else if(_UO.method==US_CM_VCNEB){ /* --- tentative at adding VCNEB, which format is different**/ /* ^^^ *BUT unfortunately, we NEED a vasp5 output (VCNEB stayed at VASP4) */ /* thus we create a new file called transitionPath_POSCARs5 which is a * translation of transitionPath_POSCARs for VASP5...*/ - atoms = g_strdup_printf("%s",elements[_UC.spe_Z[0]].symbol); - for(idx=1;idx<_UC.nspecies;idx++){ - line = g_strdup_printf("%s %s",atoms,elements[_UC.spe_Z[idx]].symbol); + atoms = g_strdup_printf("%s",elements[_UO.spe_Z[0]].symbol); + for(idx=1;idx<_UO.nspecies;idx++){ + line = g_strdup_printf("%s %s",atoms,elements[_UO.spe_Z[idx]].symbol); g_free(atoms); atoms=line; } @@ -834,13 +1197,13 @@ fprintf(stdout,"#DBG: USPEX[VCNEB]: NATOMS=%i ATOMS=%s\n",natoms,atoms); /*translate input VASP4 into proper VASP5*/ rewind(f_src); idx=0; - _UC.num_struct=0; + _UO.num_struct=0; line = file_read_line(f_src); while(line){ fprintf(f_dest,"%s",line); if (find_in_string("Image",line) != NULL) { idx=0; - _UC.num_struct++; + _UO.num_struct++; } if(idx==4) fprintf(f_dest,"%s\n",atoms); idx++; @@ -851,13 +1214,13 @@ fprintf(stdout,"#DBG: USPEX[VCNEB]: NATOMS=%i ATOMS=%s\n",natoms,atoms); fclose(f_dest); fclose(vf); g_free(atoms); - _UC.ind=g_malloc((_UC.num_struct)*sizeof(uspex_individual)); + _UO.ind=g_malloc((_UO.num_struct)*sizeof(uspex_individual)); /* --- read energies from the Energy file */ g_free(aux_file); aux_file = g_strdup_printf("%s%s",res_folder,"Energy"); vf=fopen(aux_file,"rt"); if (!vf) { - g_free(_UC.ind); + g_free(_UO.ind); line = g_strdup_printf("ERROR: can't open USPEX Energy file!\n"); gui_text_show(ERROR, line); g_free(line); @@ -874,26 +1237,26 @@ fprintf(stdout,"#DBG: USPEX[VCNEB]: NATOMS=%i ATOMS=%s\n",natoms,atoms); while((ptr)&&(*ptr==' ')) ptr++;/*skip blanks*/ }/*line should now point to the first data line*/ /*get first energy*/ - _UC.best_ind=g_malloc((1+_UC.num_struct)*sizeof(gint)); - e = g_malloc((_UC.num_struct+1)*sizeof(gdouble)); - e[0]=(gdouble) _UC.num_struct;/*first element is the size*/ + _UO.best_ind=g_malloc((1+_UO.num_struct)*sizeof(gint)); + e = g_malloc((_UO.num_struct+1)*sizeof(gdouble)); + e[0]=(gdouble) _UO.num_struct;/*first element is the size*/ sscanf(line," %*i %lf %*s",&(e[1])); e[1] /= (gdouble)natoms; - _UC.min_E=e[1]; - _UC.max_E=e[1]; - for(idx=0;idx<_UC.num_struct;idx++){ + _UO.min_E=e[1]; + _UO.max_E=e[1]; + for(idx=0;idx<_UO.num_struct;idx++){ if(!line) break;/*<- useful? */ - sscanf(line," %*i %lf %*s",&(_UC.ind[idx].energy)); - _UC.ind[idx].atoms=g_malloc(_UC.nspecies*sizeof(gint)); - _UC.ind[idx].natoms=natoms;/*<-constant*/ - _UC.ind[idx].E = _UC.ind[idx].energy / (gdouble)_UC.ind[idx].natoms; - _UC.ind[idx].gen=idx;/*<- this is actually *not* true*/ - _UC.best_ind[idx+1]=idx; - e[idx+1]=_UC.ind[idx].E; - if(e[idx+1]<_UC.min_E) _UC.min_E=e[idx+1]; - if(e[idx+1]>_UC.max_E) _UC.max_E=e[idx+1]; + sscanf(line," %*i %lf %*s",&(_UO.ind[idx].energy)); + _UO.ind[idx].atoms=g_malloc(_UO.nspecies*sizeof(gint)); + _UO.ind[idx].natoms=natoms;/*<-constant*/ + _UO.ind[idx].E = _UO.ind[idx].energy / (gdouble)_UO.ind[idx].natoms; + _UO.ind[idx].gen=idx;/*<- this is actually *not* true*/ + _UO.best_ind[idx+1]=idx; + e[idx+1]=_UO.ind[idx].E; + if(e[idx+1]<_UO.min_E) _UO.min_E=e[idx+1]; + if(e[idx+1]>_UO.max_E) _UO.max_E=e[idx+1]; #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UC.ind[idx].gen,_UC.ind[idx].natoms,_UC.ind[idx].energy,e[idx]); +fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.ind[idx].gen,_UO.ind[idx].natoms,_UO.ind[idx].energy,e[idx]); #endif g_free(line); line = file_read_line(vf); @@ -901,13 +1264,13 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UC.i fclose(vf); g_free(aux_file); /*create the reduced index table*/ - _UC.red_index=g_malloc(_UC.num_struct*sizeof(gint)); - for(idx=0;idx<_UC.num_struct;idx++) _UC.red_index[idx]=idx; + _UO.red_index=g_malloc(_UO.num_struct*sizeof(gint)); + for(idx=0;idx<_UO.num_struct;idx++) _UO.red_index[idx]=idx; aux_file = g_strdup_printf("%s%s",res_folder,"transitionPath_POSCARs5"); /* --- reopen the newly created transitionPath_POSCARs5 file for reading <- this will be our new model file*/ vf=fopen(aux_file,"rt"); if (!vf) {/*very unlikely: we just create it*/ - g_free(_UC.ind); + g_free(_UO.ind); line = g_strdup_printf("ERROR: can't open USPEX transitionPath_POSCARs5 file!\n"); gui_text_show(ERROR, line); g_free(line); @@ -938,17 +1301,17 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UC.i fclose(vf); /*do a "best" graph with each image*/ - _UC.graph_best=graph_new("PATH", model); - _UC.num_gen=_UC.num_struct; + _UO.graph_best=graph_new("PATH", model); + _UO.num_gen=_UO.num_struct; graph_add_borned_data( - _UC.num_gen,e,0,_UC.num_gen, - _UC.min_E-(_UC.max_E-_UC.min_E)*0.05,_UC.max_E+(_UC.max_E-_UC.min_E)*0.05,GRAPH_USPEX_BEST,_UC.graph_best); + _UO.num_gen,e,0,_UO.num_gen, + _UO.min_E-(_UO.max_E-_UO.min_E)*0.05,_UO.max_E+(_UO.max_E-_UO.min_E)*0.05,GRAPH_USPEX_BEST,_UO.graph_best); g_free(e); /*set ticks*/ - if(_UC.num_gen>15) ix=5; - else ix=_UC.num_gen+1; - graph_set_xticks(TRUE,ix,_UC.graph_best); - graph_set_yticks(TRUE,5,_UC.graph_best); + if(_UO.num_gen>15) ix=5; + else ix=_UO.num_gen+1; + graph_set_xticks(TRUE,ix,_UO.graph_best); + graph_set_yticks(TRUE,5,_UO.graph_best); /*refresh model*/ @@ -979,7 +1342,7 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UC.i } gint read_frame_uspex(FILE *vf, struct model_pak *model){ gchar *line; - uspex_output_struct *uspex_calc=model->uspex; + uspex_output_struct *uspex_output=model->uspex; long int vfpos;/*to counter _BUG_ where loading a raw frame does not update model->cur_frame*/ gchar *ptr; gint idx=0; @@ -996,10 +1359,10 @@ sscanf(ptr,"%i%*s",&idx); fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ if(vasp_load_poscar5(vf,model)<0) return 3; /* in case of meta idx is *not* the real number of the structure */ -/* now the index should always be _UC.red_index[idx-1] <- I THINK*/ - line=g_strdup_printf("%lf eV",_UC.ind[_UC.red_index[idx]].energy); +/* now the index should always be _UO.red_index[idx-1] <- I THINK*/ + line=g_strdup_printf("%lf eV",_UO.ind[_UO.red_index[idx]].energy); property_add_ranked(3, "Energy", line, model); - model->volume=_UC.ind[_UC.red_index[idx]].volume; + model->volume=_UO.ind[_UO.red_index[idx]].volume; g_free(line); line=g_strdup_printf("%i",idx); property_add_ranked(8, "Structure", line, model); @@ -1007,5 +1370,5 @@ fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ return 0; } -#undef _UC +#undef _UO diff --git a/src/file_uspex.h b/src/file_uspex.h index 6105b8e..dbfc921 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -26,67 +26,64 @@ typedef enum {/*released USPEX calculation methods as of 2018 (5)*/ US_CM_USPEX, /*USPEX*/ US_CM_META, /*metadynamics*/ US_CM_VCNEB, /*VC-NEB*/ - US_CM_PSO, /*PSO*/ + US_CM_PSO, /*PSO, unsupported*/ + US_CM_UNKNOWN, /*reserved for future use*/ } uspex_method; +typedef enum { + US_OT_ENTHALPY=1, /*most stable structure*/ + US_OT_VOLUME=2, /*min volume*/ + US_OT_HARDNESS=3, /*max hardness*/ + US_OT_ORDER=4, /*most ordered structure*/ + US_OT_DISTANCE=5, /*max structure */ + US_OT_DIELEC_S=6, /*max dielectric suseptibility*/ + US_OT_GAP=7, /*max band gap*/ + US_OT_DIELEC_GAP=8, /*max energy storage capacity*/ + US_OT_MAG=9, /*max magnetization*/ + US_OT_QE=10, /*max stucture quasientropy*/ +/*elasticity related*/ + US_OT_BULK_M=1101, /*max bulk modulus*/ + US_OT_SHEAR_M=1102, /*max shear modulus*/ + US_OT_YOUNG_M=1103, /*max Young modulus*/ + US_OT_POISSON=1104, /*max Poisson modulus*/ + US_OT_PUGH_R=1105, /*max Pugh modulus ratio*/ + US_OT_VICKERS_H=1106, /*max Vickers hardness*/ + US_OT_FRACTURE=1107, /*max fracture toughness*/ + US_OT_DEBYE_T=1108, /*max Debye temperature*/ + US_OT_SOUND_V=1109, /*max sound velocity*/ + US_OT_SWAVE_V=1110, /*max S-wave velocity*/ + US_OT_PWAVE_V=1111, /*max P-wave velocity*/ + US_OT_UNKNOWN=0, /*reserved for future use*/ +} uspex_opt; + typedef struct { - gint gen; /*generation of this individual*/ - gint natoms; /*number of atoms*/ - gint *atoms; /*number of atoms per species*/ - gdouble energy; /*total energy*/ - gdouble E; /*reduce energy / atoms*/ - gdouble fitness; /*NEW: fitness*/ - gdouble volume; /*total volume*/ + gint gen; /*generation of this individual*/ + gint natoms; /*number of atoms*/ + gint *atoms; /*number of atoms per species*/ + gdouble energy; /*total energy*/ + gdouble E; /*reduce energy / atoms*/ + gdouble fitness; /*NEW: fitness*/ + gdouble volume; /*total volume*/ } uspex_individual; -/* global output structure */ -typedef struct { -/*name*/ - gchar *name; - gint version; -/*system parameters*/ - uspex_method method; - gint type; - /* in detail */ - gint dim; - gboolean mol; - gboolean var; - /* optimization */ - gint opt_type; - gboolean have_fitness; -/*structures*/ - gint num_gen; - gint num_struct; - gint nspecies; /*number of species*/ - gint *spe_Z; /*atomic number of each species*/ - gint *red_index; /*in case not all structure are displayed (ie. META)*/ - gdouble min_E; - gdouble max_E; - uspex_individual *ind; - gint num_best; - gint *best_ind; -/*interpretation*/ - gpointer graph; - gpointer graph_best; - gpointer graph_comp; -} uspex_output_struct; /* USPEX calculation structure */ typedef struct { /*additional controls*/ gchar *name; /*the job name*/ gint special; /*special tag*/ - uspex_output_struct ouput; /*output structure (once/if output is loaded)*/ /*4.1 Type of run & System*/ uspex_method calculationMethod; /*supported calculation methods*/ gint calculationType; /*supported calculation types*/ gint _calctype_dim; /*HIDDEN: X.. digit in calculation type: dimension*/ gboolean _calctype_mol; /*HIDDEN: .X. digit in calculation type: molecular*/ gboolean _calctype_var; /*HIDDEN: ..X digit in calculation type: variable composition*/ - gint optType; /* optimization property*/ + uspex_opt optType; /* optimization property*/ + gint _nspecies; /*HIDDEN: number of different species*/ gint *atomType; /*atomic number of each species*/ + gint _var_nspecies; /*HIDDEN: numer of numSpecies blocks*/ gint *numSpecies; /*number of species for each type*/ gdouble ExternalPressure; /*external pressure*/ - gint valences; /*valence for each species*/ + gint *valences; /*valence for each species*/ gdouble *goodBonds; /*minimum bond valences*/ gboolean checkMolecules; /*check molecules*/ gboolean checkConnectivity; /*check connectivity*/ @@ -112,13 +109,15 @@ typedef struct { gdouble mutationDegree; /*max displacement (Ang) in softmutation*/ gdouble mutationRate; /*standard deviation in the strain matrix for lattice mutation*/ gdouble DisplaceInLatmutation; /*max displacement in sofmutation of lattice mutation*/ - gboolean autofrac; /*automatic evolution of variation operators*/ + gboolean AutoFrac; /*automatic evolution of variation operators*/ /*4.5 Constrains*/ gdouble minVectorLength; /*minimum length of a cell parameter*/ gdouble *IonDistances; /*triangular-matrix of the minimum allowed interatomic distances*/ gint constraint_enhancement; /*allow c_e times stricter constraints of IonDistances*/ + gint _nmolecules; /*HIDDEN: number of molecules*/ gdouble *MolCenters; /*triangular-matrix of minimal distances between centers of molecules*/ /*4.6 Cell*/ + gint _nlatticelines; /*HIDDEN: number of lines in Latticevalues*/ gdouble *Latticevalues; /*initial volume/parameter of the unit cell*/ gint splitInto; /*number of subcells into which unit cell is split*/ /*4.7 Restart*/ @@ -131,7 +130,7 @@ typedef struct { gint numParallelCalcs; /*number of structure relaxations at a time (in parallel)*/ gchar *commandExecutable; /*executable file/command for each optimization step*/ gint whichCluster; /*type of job-submission*/ - gchar *remoteFolder; /*remote folder where calcualtion is performed (whichCluster=2)*/ + gchar *remoteFolder; /*remote folder where calculation is performed (whichCluster=2)*/ gboolean PhaseDiagram; /*calculate a crude phase diagram w/ (rough) transition pressure*/ /*4.9 fingerprint*/ gdouble RmaxFing; /*the distance cutoff (Ang)*/ @@ -210,8 +209,39 @@ typedef struct { gint PrintStep; /*save VC-NEB restart files in STEP directory every PS steps*/ /*6.3 Set initial pathway in VC-NEB*/ /*no keyword in this section*/ - } uspex_calc_struct; +/* global output structure */ +typedef struct { +/*name*/ + gchar *name; + gint version; + uspex_calc_struct calc; +/*system parameters*/ + uspex_method method; + gint type; + /* in detail */ + gint dim; + gboolean mol; + gboolean var; + /* optimization */ + gint opt_type; + gboolean have_fitness; +/*structures*/ + gint num_gen; + gint num_struct; + gint nspecies; /*number of species*/ + gint *spe_Z; /*atomic number of each species*/ + gint *red_index; /*in case not all structure are displayed (ie. META)*/ + gdouble min_E; + gdouble max_E; + uspex_individual *ind; + gint num_best; + gint *best_ind; +/*interpretation*/ + gpointer graph; + gpointer graph_best; + gpointer graph_comp; +} uspex_output_struct; /* execution structure */ typedef struct { int job_id; From 6f55b36a5224525e49181b1b039e30111baafa81 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 6 Aug 2018 19:04:24 +0900 Subject: [PATCH 16/56] gui_uspex: uspex parameters III. --- src/file_uspex.c | 463 ++++++++++++++++++++++++++++++++++++++++++++++- src/file_uspex.h | 21 ++- 2 files changed, 473 insertions(+), 11 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 889e724..3140439 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -239,6 +239,13 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ g_free(line);line = file_read_line(vf);\ continue;\ } +#define __GET_CHARS(value) if (find_in_string(__Q(value),line) != NULL) {\ + ptr = g_strdup_printf("%%s : %s",__Q(value));\ + sscanf(line,ptr,&(CALC.value));\ + g_free(ptr);g_free(line);line = file_read_line(vf);\ + continue;\ +} + line = file_read_line(vf); while (line){ if (find_in_string("calculationMethod",line) != NULL) { @@ -458,7 +465,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ /*if no _nspecies, get it now*/ __NSPECIES(line); /*look for goodBonds*/ - CALC.goodBonds = g_malloc(CALC._nspecies*CALC._nspecies*sizeof(gint)); + CALC.goodBonds = g_malloc(CALC._nspecies*CALC._nspecies*sizeof(gdouble)); for(i=0;i _nlatticevalues <= 3 or bad setting*/ + if((CALC._nlatticevalues<=3)&&(CALC._nlatticevalues>1)){ + /*this may be a definition of 1, 2, or 3D cell, but why?*/ + CALC.Latticevalues = g_malloc(CALC._nlatticevalues*CALC._nlatticevalues*sizeof(gdouble)); + for(i=0;i1)){/*lattice vectors*/ + CALC.Latticevalues = g_malloc(CALC._nlatticevalues*CALC._nlatticevalues*sizeof(gdouble)); + for(i=0;i2)) { + g_free(line); + line = file_read_line(vf); + continue; + } + CALC._vcnebtype_method=i; + j-=i*100; + i=((int)(j/10))%10; + if((i<0)||(i>1)){ + g_free(line); + line = file_read_line(vf); + continue; + } + CALC._vcnebtype_img_num=(i==1); + j-=i*10; + i=j%10; + if((i<0)||(i>1)){ + g_free(line); + line = file_read_line(vf); + continue; + } + CALC._vcnebtype_spring=(i==1); + CALC.vcnebType=k; + g_free(line); + line = file_read_line(vf); + continue; + } + __GET_INT(numImages); + __GET_INT(numSteps); + __GET_INT(optReadImages); + __GET_BOOL(optimizerType); + __GET_INT(optRelaxType); + __GET_DOUBLE(dt); + __GET_DOUBLE(ConvThreshold); + __GET_DOUBLE(VarPathLength); + __GET_DOUBLE(K_min); + __GET_DOUBLE(K_max); + __GET_DOUBLE(Kconstant); + __GET_BOOL(optFreezing); + __GET_INT(optMethodCIDI); + __GET_INT(startCIDIStep); + if (find_in_string("pickupImages",line) != NULL) { + g_free(line);line = file_read_line(vf);/*go next line*/ + /*count number of picked-up images*/ + ptr=&(line[0]); + CALC._npickimg=1; + while(*ptr!='\0'){ + if(*ptr==' ') { + CALC._npickimg++; + while(g_ascii_isgraph(*ptr)) ptr++; + }else ptr++; + } + /*look for pickupImages*/ + CALC.pickupImages = g_malloc(CALC._npickimg*sizeof(gint)); + for(i=0;i Date: Tue, 7 Aug 2018 19:13:05 +0900 Subject: [PATCH 17/56] gui_uspex: uspex parameters IV. --- src/file_uspex.c | 440 +++++++++++++++++++++++++++++++---------------- src/file_uspex.h | 7 + 2 files changed, 297 insertions(+), 150 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 3140439..65fcdb7 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -58,7 +58,6 @@ extern struct sysenv_pak sysenv; extern struct elem_pak elements[]; #define DEBUG_USPEX_READ 0 -#define _UO (*uspex_output) gint read_parameter_uspex(gchar *filename, struct model_pak *model){ FILE *vf; @@ -179,36 +178,75 @@ fprintf(stdout,"#DBG: USPEX species[%i] Z=%i\n",idx,_UO.spe_Z[idx]); /*end of Parameters.txt read*/ return 0; } +void init_uspex_parameters(uspex_calc_struct *uspex_calc){ + /*init an (assumed) empty structure with default parameters*/ + /* Contrary to USPEX defaults, init default are just to prepare the calc structure. */ + _UC.name=NULL; + _UC.special=0; + _UC.calculationMethod=US_CM_UNKNOWN; + _UC.calculationType=300; + _UC._calctype_dim=3; + _UC._calctype_mol=FALSE; + _UC._calctype_var=FALSE; + _UC.optType=US_OT_ENTHALPY; + _UC._nspecies=0; + _UC.atomType=NULL; + _UC._var_nspecies=0; + _UC.numSpecies=NULL; + _UC.ExternalPressure=0.; + _UC.valences=NULL; + _UC.goodBonds=NULL; + _UC.checkMolecules=TRUE; + _UC.checkConnectivity=FALSE; + _UC.populationSize=0; + _UC.initialPopSize=0; + _UC.numGenerations=100; + _UC.stopCrit=0; + _UC.bestFrac=0.7; + _UC.keepBestHM=0; + _UC.reoptOld=FALSE; + _UC.symmetries=NULL; + _UC.fracGene=0.5; + _UC.fracRand=0.2; + _UC.fracPerm=0.; + _UC.fracAtomsMut=0.1; + _UC.fracRotMut=0.; + _UC.fracLatMut=0.; + _UC.howManySwaps=0; + _UC.specificSwaps=NULL; + _UC.mutationDegree=0; + _UC.mutationRate=0.5; + _UC.DisplaceInLatmutation=1.0; + _UC.AutoFrac=FALSE; + +} /************************************************************************/ /* Read Parameters.txt and fill keywords of uspex_calc_struct structure */ /*For reading Parameters.txt files, *not* preparing a model for display.*/ /************************************************************************/ -gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ -#define CALC (*calc) +gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ FILE *vf; long int vfpos; gchar *line=NULL; gchar *ptr; -// gchar tmp[64]; gchar c; gint i,j,k; -// gdouble d; /*tests*/ if(filename==NULL) return -1; - if(calc==NULL) return -1; + if(uspex_calc==NULL) return -1; vf = fopen(filename, "rt"); if (!vf) return -2; /**/ - CALC._nspecies=0;/*set hidden to 0*/ + _UC._nspecies=0;/*set hidden to 0*/ /*some lazy defines*/ #define __NSPECIES(line) do{\ - if(CALC._nspecies==0){\ + if(_UC._nspecies==0){\ ptr=&(line[0]);\ while(*ptr==' ') ptr++;\ - CALC._nspecies=1;\ + _UC._nspecies=1;\ while(*ptr!='\0'){\ if(*ptr==' ') {\ - CALC._nspecies++;ptr++;\ + _UC._nspecies++;ptr++;\ while(g_ascii_isgraph(*ptr)) ptr++;\ }else ptr++;\ }\ @@ -218,30 +256,30 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ #define __GET_BOOL(value) if (find_in_string(__Q(value),line)!=NULL){\ k=0;sscanf(line,"%i%*s",&(k));\ - CALC.value=(k==1);\ + _UC.value=(k==1);\ g_free(line);line = file_read_line(vf);\ continue;\ } #define __GET_INT(value) if (find_in_string(__Q(value),line) != NULL) {\ - sscanf(line,"%i%*s",&(CALC.value));\ + sscanf(line,"%i%*s",&(_UC.value));\ g_free(line);line = file_read_line(vf);\ continue;\ } #define __GET_DOUBLE(value) if (find_in_string(__Q(value),line) != NULL) {\ - sscanf(line,"%lf%*s",&(CALC.value));\ + sscanf(line,"%lf%*s",&(_UC.value));\ g_free(line);line = file_read_line(vf);\ continue;\ } #define __GET_STRING(value) if (find_in_string(__Q(value),line) != NULL) {\ g_free(line);line = file_read_line(vf);\ - CALC.value=g_strdup(line);\ + _UC.value=g_strdup(line);\ g_free(line);line = file_read_line(vf);\ g_free(line);line = file_read_line(vf);\ continue;\ } #define __GET_CHARS(value) if (find_in_string(__Q(value),line) != NULL) {\ ptr = g_strdup_printf("%%s : %s",__Q(value));\ - sscanf(line,ptr,&(CALC.value));\ + sscanf(line,ptr,&(_UC.value));\ g_free(ptr);g_free(line);line = file_read_line(vf);\ continue;\ } @@ -253,23 +291,23 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ switch(c){ case 'u': case 'U':/*USPEX method*/ - CALC.calculationMethod=US_CM_USPEX; + _UC.calculationMethod=US_CM_USPEX; break; case 'm': case 'M': - CALC.calculationMethod=US_CM_META; + _UC.calculationMethod=US_CM_META; break; case 'v': case 'V': - CALC.calculationMethod=US_CM_VCNEB; + _UC.calculationMethod=US_CM_VCNEB; break; case 'p': case 'P': /*PSO method is not supported yet*/ - CALC.calculationMethod=US_CM_PSO; + _UC.calculationMethod=US_CM_PSO; break; default: - CALC.calculationMethod=US_CM_UNKNOWN; + _UC.calculationMethod=US_CM_UNKNOWN; } g_free(line); line = file_read_line(vf); @@ -284,7 +322,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ line = file_read_line(vf); continue; } - CALC._calctype_dim=i; + _UC._calctype_dim=i; j-=i*100; i=((int)(j/10))%10; if((i<0)||(i>1)){ @@ -292,7 +330,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ line = file_read_line(vf); continue; } - CALC._calctype_mol=(i==1); + _UC._calctype_mol=(i==1); j-=i*10; i=j%10; if((i<0)||(i>1)){ @@ -300,8 +338,8 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ line = file_read_line(vf); continue; } - CALC._calctype_var=(i==1); - CALC.calculationType=k; + _UC._calctype_var=(i==1); + _UC.calculationType=k; g_free(line); line = file_read_line(vf); continue; @@ -310,70 +348,70 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ k=0;sscanf(line,"%i%*s",&(k)); switch (k){ case 1: - CALC.optType=US_OT_ENTHALPY; + _UC.optType=US_OT_ENTHALPY; break; case 2: - CALC.optType=US_OT_VOLUME; + _UC.optType=US_OT_VOLUME; break; case 3: - CALC.optType=US_OT_HARDNESS; + _UC.optType=US_OT_HARDNESS; break; case 4: - CALC.optType=US_OT_ORDER; + _UC.optType=US_OT_ORDER; break; case 5: - CALC.optType=US_OT_DISTANCE; + _UC.optType=US_OT_DISTANCE; break; case 6: - CALC.optType=US_OT_DIELEC_S; + _UC.optType=US_OT_DIELEC_S; break; case 7: - CALC.optType=US_OT_GAP; + _UC.optType=US_OT_GAP; break; case 8: - CALC.optType=US_OT_DIELEC_GAP; + _UC.optType=US_OT_DIELEC_GAP; break; case 9: - CALC.optType=US_OT_MAG; + _UC.optType=US_OT_MAG; break; case 10: - CALC.optType=US_OT_QE; + _UC.optType=US_OT_QE; break; case 1101: - CALC.optType=US_OT_BULK_M; + _UC.optType=US_OT_BULK_M; break; case 1102: - CALC.optType=US_OT_SHEAR_M; + _UC.optType=US_OT_SHEAR_M; break; case 1103: - CALC.optType=US_OT_YOUNG_M; + _UC.optType=US_OT_YOUNG_M; break; case 1104: - CALC.optType=US_OT_POISSON; + _UC.optType=US_OT_POISSON; break; case 1105: - CALC.optType=US_OT_PUGH_R; + _UC.optType=US_OT_PUGH_R; break; case 1106: - CALC.optType=US_OT_VICKERS_H; + _UC.optType=US_OT_VICKERS_H; break; case 1107: - CALC.optType=US_OT_FRACTURE; + _UC.optType=US_OT_FRACTURE; break; case 1108: - CALC.optType=US_OT_DEBYE_T; + _UC.optType=US_OT_DEBYE_T; break; case 1109: - CALC.optType=US_OT_SOUND_V; + _UC.optType=US_OT_SOUND_V; break; case 1110: - CALC.optType=US_OT_SWAVE_V; + _UC.optType=US_OT_SWAVE_V; break; case 1111: - CALC.optType=US_OT_PWAVE_V; + _UC.optType=US_OT_PWAVE_V; break; default: - CALC.optType=US_OT_UNKNOWN; + _UC.optType=US_OT_UNKNOWN; } g_free(line); line = file_read_line(vf); @@ -384,16 +422,16 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ /*if no _nspecies, get it now*/ __NSPECIES(line); /*look for atomType*/ - CALC.atomType = g_malloc(CALC._nspecies*sizeof(gint)); - for(i=0;iMAX_ELEMENTS-1)){/*invalid Z*/ - CALC.atomType[i]=0;/*allow it for now*/ + if(g_ascii_isdigit(*ptr)) _UC.atomType[i]=g_ascii_strtod(ptr,NULL);/*user provided Z number*/ + else _UC.atomType[i]=elem_symbol_test(ptr);/*try user provided symbol*/ + if((_UC.atomType[i]<=0)||(_UC.atomType[i]>MAX_ELEMENTS-1)){/*invalid Z*/ + _UC.atomType[i]=0;/*allow it for now*/ } ptr++;i++; while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ @@ -411,20 +449,20 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ __NSPECIES(line); /*look for numSpecies*/ /*1st get the total number of lines*/ - CALC._var_nspecies=0; + _UC._var_nspecies=0; do{ g_free(line);line = file_read_line(vf);/*go next line*/ - CALC._var_nspecies++; + _UC._var_nspecies++; }while(find_in_string("umSpecies",line) == NULL); fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ line = file_read_line(vf);/*first line of numSpecies*/ - CALC.numSpecies = g_malloc(CALC._nspecies*CALC._var_nspecies*sizeof(gint)); - for(i=0;i _nlatticevalues <= 3 or bad setting*/ - if((CALC._nlatticevalues<=3)&&(CALC._nlatticevalues>1)){ + if((_UC._nlatticevalues<=3)&&(_UC._nlatticevalues>1)){ /*this may be a definition of 1, 2, or 3D cell, but why?*/ - CALC.Latticevalues = g_malloc(CALC._nlatticevalues*CALC._nlatticevalues*sizeof(gdouble)); - for(i=0;i1)){/*lattice vectors*/ - CALC.Latticevalues = g_malloc(CALC._nlatticevalues*CALC._nlatticevalues*sizeof(gdouble)); - for(i=0;i1)){/*lattice vectors*/ + _UC.Latticevalues = g_malloc(_UC._nlatticevalues*_UC._nlatticevalues*sizeof(gdouble)); + for(i=0;i<_UC._nlatticevalues*_UC._nlatticevalues;i++) _UC.Latticevalues[i]=0.; fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ g_free(line);line = file_read_line(vf);/*go next line*/ ptr=&(line[0]); j=0; - while((j1)){ @@ -935,7 +973,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ line = file_read_line(vf); continue; } - CALC._vcnebtype_img_num=(i==1); + _UC._vcnebtype_img_num=(i==1); j-=i*10; i=j%10; if((i<0)||(i>1)){ @@ -943,8 +981,8 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ line = file_read_line(vf); continue; } - CALC._vcnebtype_spring=(i==1); - CALC.vcnebType=k; + _UC._vcnebtype_spring=(i==1); + _UC.vcnebType=k; g_free(line); line = file_read_line(vf); continue; @@ -967,20 +1005,20 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *calc){ g_free(line);line = file_read_line(vf);/*go next line*/ /*count number of picked-up images*/ ptr=&(line[0]); - CALC._npickimg=1; + _UC._npickimg=1; while(*ptr!='\0'){ if(*ptr==' ') { - CALC._npickimg++; + _UC._npickimg++;ptr++; while(g_ascii_isgraph(*ptr)) ptr++; }else ptr++; } /*look for pickupImages*/ - CALC.pickupImages = g_malloc(CALC._npickimg*sizeof(gint)); - for(i=0;i-1){ } g_free(line); /* --- and close */ - fclose(vf); + fclose(vf);vf=NULL; /* --- READ Parameters.txt */ +/* XXX XXX XXX */ + init_uspex_parameters(&(_UO.calc)); + aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); + if(read_uspex_parameters(aux_file,&(_UO.calc))){ + line = g_strdup_printf("ERROR: reading USPEX REAL Parameter.txt file!\n"); + gui_text_show(ERROR, line); + g_free(line); + g_free(aux_file); + goto uspex_fail; + } + g_free(aux_file); + +// if(dump_uspex_parameters("out.uspex",&(_UO.calc))){ +// fprintf(stdout,"ERR: couldn't write Parameters.txt file: out.uspex\n"); +// } + +/* XXX XXX XXX */ aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); if(read_parameter_uspex(aux_file,model)!=0) { line = g_strdup_printf("ERROR: reading USPEX Parameter.txt file!\n"); @@ -1292,7 +1423,10 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); - else fclose(vf); + else { + fclose(vf); + vf=NULL; + } }else{ aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); } @@ -1396,7 +1530,10 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); - else fclose(vf); + else { + fclose(vf); + vf=NULL; + } }else{ aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); } @@ -1412,7 +1549,10 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); - else fclose(vf); + else { + fclose(vf); + vf=NULL; + } }else{ aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); } @@ -1425,7 +1565,7 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ goto uspex_fail; } read_frame_uspex(vf,model);/*open first frame*/ - fclose(vf); + fclose(vf);vf=NULL; /* --- Prepare the summary graph */ /*no need to load BESTIndividuals since we already know everything from Individuals*/ @@ -1671,7 +1811,7 @@ fprintf(stdout,"#DBG: USPEX[VCNEB]: NATOMS=%i ATOMS=%s\n",natoms,atoms); } fclose(f_src); fclose(f_dest); - fclose(vf); + fclose(vf);vf=NULL; g_free(atoms); _UO.ind=g_malloc((_UO.num_struct)*sizeof(uspex_individual)); /* --- read energies from the Energy file */ @@ -1720,7 +1860,7 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i g_free(line); line = file_read_line(vf); } - fclose(vf); + fclose(vf);vf=NULL; g_free(aux_file); /*create the reduced index table*/ _UO.red_index=g_malloc(_UO.num_struct*sizeof(gint)); @@ -1757,7 +1897,7 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i g_free(aux_file); rewind(vf); read_frame_uspex(vf,model);/*open first frame*/ - fclose(vf); + fclose(vf);vf=NULL; /*do a "best" graph with each image*/ _UO.graph_best=graph_new("PATH", model); @@ -1796,7 +1936,7 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i line = g_strdup_printf("ERROR: loading USPEX failed!\n"); gui_text_show(ERROR, line); g_free(line); - fclose(vf); + if(vf!=NULL) fclose(vf); return 3; } gint read_frame_uspex(FILE *vf, struct model_pak *model){ diff --git a/src/file_uspex.h b/src/file_uspex.h index ae12d02..ae6faba 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -22,6 +22,13 @@ The GNU GPL can also be found at http://www.gnu.org /* header for USPEX file */ +/*defines*/ +#define _UO (*uspex_output) +#define _UC (*uspex_calc) + + + +/*structures*/ typedef enum {/*released USPEX calculation methods as of 2018 (5)*/ US_CM_USPEX, /*USPEX*/ US_CM_META, /*metadynamics*/ From 00f12c60d71292b0e051e140917076d2f2d3146e Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 8 Aug 2018 20:16:10 +0900 Subject: [PATCH 18/56] gui_uspex: uspex parameters V. --- src/file_uspex.c | 352 ++++++++++++++++++++++++++++++++++------------- src/file_uspex.h | 9 +- 2 files changed, 257 insertions(+), 104 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 65fcdb7..c26d10b 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -176,6 +176,7 @@ fprintf(stdout,"#DBG: USPEX species[%i] Z=%i\n",idx,_UO.spe_Z[idx]); /*end of Parameters.txt read*/ + fclose(vf); return 0; } void init_uspex_parameters(uspex_calc_struct *uspex_calc){ @@ -183,7 +184,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ /* Contrary to USPEX defaults, init default are just to prepare the calc structure. */ _UC.name=NULL; _UC.special=0; - _UC.calculationMethod=US_CM_UNKNOWN; + _UC.calculationMethod=US_CM_USPEX; _UC.calculationType=300; _UC._calctype_dim=3; _UC._calctype_mol=FALSE; @@ -218,26 +219,99 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.mutationRate=0.5; _UC.DisplaceInLatmutation=1.0; _UC.AutoFrac=FALSE; - + _UC.minVectorLength=0.; + _UC.IonDistances=NULL; + _UC.constraint_enhancement=TRUE; + _UC.MolCenters=NULL; + _UC.Latticevalues=NULL; + _UC.splitInto=NULL; + _UC.abinitioCode=NULL; + _UC.KresolStart=NULL; + _UC.vacuumSize=NULL; + _UC.numParallelCalcs=1; + _UC.commandExecutable=NULL; + _UC.whichCluster=0; + _UC.remoteFolder=NULL; + _UC.PhaseDiagram=FALSE; + _UC.RmaxFing=10.0; + _UC.deltaFing=0.08; + _UC.sigmaFing=0.03; + _UC.antiSeedsActivation=5000; + _UC.antiSeedsMax=0.; + _UC.antiSeedsSigma=0.001; + _UC.doSpaceGroup=TRUE; + _UC.SymTolerance=0.1; + _UC.repeatForStatistics=1; + _UC.stopFitness=0.; + _UC.collectForces=FALSE; + _UC.ordering_active=TRUE; + _UC.symmetrize=FALSE; + _UC.valenceElectr=NULL; + _UC.percSliceShift=1.0; + _UC.dynamicalBestHM=2; + _UC.softMutOnly=NULL; + _UC.maxDistHeredity=0.5; + _UC.manyParents=0; + _UC.minSlice=0.; + _UC.maxSlice=0.; + _UC.numberparents=2; + _UC.thicknessS=2.0; + _UC.thicknessB=3.0; + _UC.reconstruct=1; + _UC.firstGeneMax=11; + _UC.minAt=0; + _UC.maxAt=0; + _UC.fracTrans=0.1; + _UC.howManyTrans=0.2; + _UC.specificTrans=NULL; + _UC.GaussianWidth=0.; + _UC.GaussianHeight=0.; + _UC.FullRelax=2; + _UC.maxVectorLength=0.; + _UC.PSO_softMut=1; + _UC.PSO_BestStruc=1; + _UC.PSO_BestEver=1; + _UC.vcnebType=110; + _UC._vcnebtype_method=1; + _UC._vcnebtype_img_num=TRUE; + _UC._vcnebtype_spring=FALSE; + _UC.numImages=9; + _UC.numSteps=200; + _UC.optReadImages=2; + _UC.optimizerType=FALSE; + _UC.optRelaxType=3; + _UC.dt=0.05; + _UC.ConvThreshold=0.003; + _UC.VarPathLength=0.; + _UC.K_min=5; + _UC.K_max=5; + _UC.Kconstant=5; + _UC.optFreezing=FALSE; + _UC.optMethodCIDI=0; + _UC.startCIDIStep=100; + _UC.pickupImages=NULL; + _UC.FormatType=2;/*MUST BE VASP FORMAT!*/ + _UC.PrintStep=1; } /************************************************************************/ /* Read Parameters.txt and fill keywords of uspex_calc_struct structure */ /*For reading Parameters.txt files, *not* preparing a model for display.*/ /************************************************************************/ -gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ +uspex_calc_struct *read_uspex_parameters(gchar *filename){ FILE *vf; long int vfpos; gchar *line=NULL; gchar *ptr; gchar c; gint i,j,k; + uspex_calc_struct *uspex_calc; /*tests*/ - if(filename==NULL) return -1; - if(uspex_calc==NULL) return -1; + if(filename==NULL) return NULL; vf = fopen(filename, "rt"); - if (!vf) return -2; + if (!vf) return NULL; /**/ - _UC._nspecies=0;/*set hidden to 0*/ + uspex_calc = g_malloc(sizeof(uspex_calc_struct)); + init_uspex_parameters(uspex_calc); /*some lazy defines*/ #define __NSPECIES(line) do{\ if(_UC._nspecies==0){\ @@ -285,7 +359,10 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ } line = file_read_line(vf); - while (line){ + while(line){ +#if DEBUG_USPEX_READ +fprintf(stdout,"#DBG: PROBE LINE: %s",line); +#endif if (find_in_string("calculationMethod",line) != NULL) { c='\0';sscanf(line,"%c%*s",&(c)); switch(c){ @@ -425,7 +502,6 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ _UC.atomType = g_malloc(_UC._nspecies*sizeof(gint)); for(i=0;i<_UC._nspecies;i++) _UC.atomType[i]=0; ptr=&(line[0]);i=0; -// while(*ptr==' ') ptr++;/*skip initial space (if any)*/ while((*ptr!='\n')&&(*ptr!='\0')){ if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ if(g_ascii_isdigit(*ptr)) _UC.atomType[i]=g_ascii_strtod(ptr,NULL);/*user provided Z number*/ @@ -447,13 +523,12 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ g_free(line);line = file_read_line(vf);/*go next line*/ /*if no _nspecies, get it now*/ __NSPECIES(line); - /*look for numSpecies*/ /*1st get the total number of lines*/ _UC._var_nspecies=0; do{ g_free(line);line = file_read_line(vf);/*go next line*/ _UC._var_nspecies++; - }while(find_in_string("umSpecies",line) == NULL); + }while(find_in_string("EndNumSpecies",line) == NULL); fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ line = file_read_line(vf);/*first line of numSpecies*/ _UC.numSpecies = g_malloc(_UC._nspecies*_UC._var_nspecies*sizeof(gint)); @@ -469,10 +544,6 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ g_free(line); line = file_read_line(vf); } - if (find_in_string("umSpecies",line) != NULL) { - g_free(line); - line = file_read_line(vf); - } g_free(line); line = file_read_line(vf); continue; @@ -506,7 +577,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ _UC.goodBonds = g_malloc(_UC._nspecies*_UC._nspecies*sizeof(gdouble)); for(i=0;i<_UC._nspecies*_UC._nspecies;i++) _UC.goodBonds[i]=0.; j=0; - while((j<_UC._nspecies)&&(find_in_string("oodBonds",line)==NULL)){ + while((j<_UC._nspecies)&&(find_in_string("EndGoodBonds",line)==NULL)){ ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ @@ -518,10 +589,6 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ g_free(line); line = file_read_line(vf); } - if(find_in_string("oodBonds",line) != NULL){ - g_free(line); - line = file_read_line(vf); - } g_free(line); line = file_read_line(vf); continue; @@ -557,7 +624,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ _UC.IonDistances = g_malloc(_UC._nspecies*_UC._nspecies*sizeof(gdouble)); for(i=0;i<_UC._nspecies*_UC._nspecies;i++) _UC.IonDistances[i]=0.; j=0; - while((j<_UC._nspecies)&&(find_in_string("onDistances",line)==NULL)){ + while((j<_UC._nspecies)&&(find_in_string("EndDistances",line)==NULL)){ ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ @@ -569,10 +636,6 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ g_free(line); line = file_read_line(vf); } - if(find_in_string("onDistances",line) != NULL){ - g_free(line); - line = file_read_line(vf); - } g_free(line); line = file_read_line(vf); continue; @@ -605,10 +668,6 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ g_free(line); line = file_read_line(vf); } - if(find_in_string("EndMol",line) != NULL){ - g_free(line); - line = file_read_line(vf); - } g_free(line); line = file_read_line(vf); continue; @@ -643,38 +702,15 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ ptr++;i++; while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ } - }else{/*varcomp but more than one line -> _nlatticevalues <= 3 or bad setting*/ - if((_UC._nlatticevalues<=3)&&(_UC._nlatticevalues>1)){ - /*this may be a definition of 1, 2, or 3D cell, but why?*/ - _UC.Latticevalues = g_malloc(_UC._nlatticevalues*_UC._nlatticevalues*sizeof(gdouble)); - for(i=0;i<_UC._nlatticevalues*_UC._nlatticevalues;i++) _UC.Latticevalues[i]=0.; - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - g_free(line);line = file_read_line(vf);/*go next line*/ - ptr=&(line[0]); - j=0; - while((j<_UC._nlatticevalues)&&(find_in_string("Endvalues",line)==NULL)){ - ptr=&(line[0]);i=0; - while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - sscanf(ptr,"%lf%*s",&(_UC.Latticevalues[i+j*_UC._nlatticevalues])); - ptr++;i++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ - } - j++; - g_free(line); - line = file_read_line(vf); - } - }else{/*this is a bad setting*/ - g_free(line); - line = g_strdup_printf("ERROR: USPEX bad Latticevalues/varcomp setting in Parameters.txt!\n"); - gui_text_show(ERROR, line); - g_free(line); - g_free(line);line = file_read_line(vf);/*go next line*/ - } + }else{/*varcomp but more than one line -> bad setting*/ + g_free(line); + line = g_strdup_printf("ERROR: USPEX bad Latticevalues volumes settings in varcomp Parameters.txt!\n"); + gui_text_show(ERROR, line); + g_free(line);line = file_read_line(vf);/*go next line*/ } }else{ /*NOT varcomp calculation: should be a crystal definition*/ - if(_UC._nlatticevalues==6){/*crystal definition*/ + if(_UC._nlatticevalues==6){/*crystal definition -- should we test for Endvalues?*/ _UC.Latticevalues = g_malloc(_UC._nlatticevalues*sizeof(gdouble)); for(i=0;i<_UC._nlatticevalues;i++) _UC.Latticevalues[i]=0.; fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ @@ -715,14 +751,9 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ g_free(line); line = g_strdup_printf("ERROR: USPEX bad Latticevalues setting in Parameters.txt!\n"); gui_text_show(ERROR, line); - g_free(line); g_free(line);line = file_read_line(vf);/*go next line*/ } } - if(find_in_string("Endvalues",line) != NULL){ - g_free(line); - line = file_read_line(vf); - } g_free(line); line = file_read_line(vf); continue; @@ -769,7 +800,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ }/*note that the METADYNAMICS parenthesis are ignored as well*/ /*look for abinitioCode*/ _UC.abinitioCode = g_malloc(_UC._num_opt_steps*sizeof(gint)); - for(i=0;i<_UC._nsplits;i++) _UC.abinitioCode[i]=0; + for(i=0;i<_UC._num_opt_steps;i++) _UC.abinitioCode[i]=0; ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ if((*ptr==' ')||(*ptr=='(')) while((*ptr==' ')||(*ptr=='(')) ptr++;/*skip space(s) & parenthesis*/ @@ -787,7 +818,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ g_free(line);line = file_read_line(vf);/*go next line*/ /*in my understanding, there is either 1 or _num_opt_steps values of KresolStart*/ _UC.KresolStart = g_malloc(_UC._num_opt_steps*sizeof(gdouble)); - for(i=0;i<_UC._nsplits;i++) _UC.KresolStart[i]=0.; + for(i=0;i<_UC._num_opt_steps;i++) _UC.KresolStart[i]=0.; ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ @@ -805,7 +836,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ g_free(line);line = file_read_line(vf);/*go next line*/ /*in my understanding, there is also either 1 or _num_opt_steps values of vacuumSize*/ _UC.vacuumSize = g_malloc(_UC._num_opt_steps*sizeof(gdouble)); - for(i=0;i<_UC._nsplits;i++) _UC.vacuumSize[i]=0.; + for(i=0;i<_UC._num_opt_steps;i++) _UC.vacuumSize[i]=0.; ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ @@ -825,7 +856,7 @@ gint read_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ /*there is 11)&&(_UC.MolCenters==NULL)) { + line = g_strdup_printf("ERROR: USPEX - molecular calculation but missing MolCenters!\n"); + gui_text_show(ERROR, line);g_free(line); + return -5; + } + if((_UC.repeatForStatistics>1)&&(_UC.stopFitness==0.)){ + line = g_strdup_printf("ERROR: USPEX - repeatForStatistics is >1 but stopFitness is 0.!\n"); + gui_text_show(ERROR, line);g_free(line); + return -5; + } + if((_UC._calctype_var)&&(_UC.minAt==0)){ + line = g_strdup_printf("ERROR: USPEX - varcomp calculation but missing minAt!\n"); + gui_text_show(ERROR, line);g_free(line); + return -5; + } + if((_UC._calctype_var)&&(_UC.maxAt==0)){ + line = g_strdup_printf("ERROR: USPEX - varcomp calculation but missing maxAt!\n"); + gui_text_show(ERROR, line);g_free(line); + return -5; + } + if((_UC.calculationMethod==US_CM_META)&&(_UC.maxVectorLength=0.)){ + line = g_strdup_printf("ERROR: USPEX - META calculation but missong maxVectorLength!\n"); + gui_text_show(ERROR, line);g_free(line); + return -5; + } + /*open output*/ + vf = fopen(filename, "w"); + if (!vf) return -2; + /*output resulting "Parameter.txt" input*/ fprintf(vf,"PARAMETERS EVOLUTIONARY ALGORITHM\n"); fprintf(vf,"GENERATED BY GDIS %4.2f.%d (C) %d\n",VERSION,PATCH,YEAR); if(_UC.name==NULL) _UC.name=g_strdup("(unnamed)"); @@ -1083,6 +1182,7 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ line=g_strdup_printf("* TYPE OF RUN AND SYSTEM *"); __TITLE(line); g_free(line); + /*always print:*/ switch(_UC.calculationMethod){ case US_CM_USPEX: fprintf(vf,"USPEX\t: calculationMethod\n"); @@ -1102,15 +1202,72 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ } __OUT_INT(calculationType); __OUT_INT(optType); - fprintf(vf,"%% atomType\n"); - for(i=0;i<_UC._nspecies;i++) fprintf(vf,"%i ",_UC.atomType[i]); - fprintf(vf,"\n"); - fprintf(vf,"%% EndAtomType\n"); - - - + __OUT_BK_INT(atomType,"EndAtomType",_UC._nspecies); + __OUT_BK_INT(numSpecies,"EndNumSpecies",_UC._var_nspecies); + __OUT_DOUBLE(ExternalPressure); + /*print when NOT default or unset*/ + if(_UC.valences!=NULL) __OUT_BK_INT(valences,"endValences",_UC._nspecies); + if(_UC.goodBonds!=NULL) __OUT_TMAT_DOUBLE(goodBonds,"EndGoodBonds",_UC._nspecies);/*TODO: use of a single value is unsupported*/ + if(!_UC.checkMolecules) __OUT_BOOL(checkMolecules); + if(_UC.checkConnectivity) __OUT_BOOL(checkConnectivity); + line=g_strdup_printf("* POPULATION *"); + __TITLE(line); + g_free(line); + if(_UC.populationSize!=0) __OUT_INT(populationSize); + if(_UC.initialPopSize!=0) __OUT_INT(initialPopSize); + if(_UC.numGenerations!=100) __OUT_INT(numGenerations); + if(_UC.stopCrit!=0) __OUT_INT(stopCrit); + line=g_strdup_printf("* SURVIVAL OF THE FITTEST & SELECTION *"); + __TITLE(line); + g_free(line); + if(_UC.bestFrac!=0.7) __OUT_DOUBLE(bestFrac); + if(_UC.keepBestHM!=0) __OUT_INT(keepBestHM); + if(_UC.reoptOld) __OUT_BOOL(reoptOld); + line=g_strdup_printf("* STRUCTURE GENERATION & VARIATION OPERATORS *"); + __TITLE(line); + g_free(line); + if(_UC.symmetries!=NULL) __OUT_BK_STRING(symmetries,"endSymmetries"); + if(_UC.fracGene!=0.5) __OUT_DOUBLE(fracGene); + if(_UC.fracRand!=0.2) __OUT_DOUBLE(fracRand); + if((_UC._nspecies>1)&&(_UC.fracPerm!=0.1)) __OUT_DOUBLE(fracPerm); + if((_UC._nspecies==1)&&(_UC.fracPerm!=0.)) __OUT_DOUBLE(fracPerm); + if(_UC.fracAtomsMut!=0.1) __OUT_DOUBLE(fracAtomsMut); + if((_UC._calctype_dim==3)&&(_UC._calctype_mol)){ + if(_UC.fracRotMut!=0.1) __OUT_DOUBLE(fracRotMut); + }else{ + if(_UC.fracRotMut!=0.) __OUT_DOUBLE(fracRotMut); + } + if((_UC.FullRelax==0)||(_UC.optRelaxType==1)){ + if(_UC.fracLatMut!=0.) __OUT_DOUBLE(fracLatMut); + }else{ + if(_UC.fracLatMut!=0.1) __OUT_DOUBLE(fracLatMut); + } + if(_UC.howManySwaps!=0) __OUT_INT(howManySwaps); + if(_UC.specificSwaps!=NULL) __OUT_BK_STRING(specificSwaps,"EndSpecific"); + if(_UC.mutationDegree!=0.) __OUT_DOUBLE(mutationDegree); + if(_UC.mutationRate!=0.5) __OUT_DOUBLE(mutationRate); + if(_UC.DisplaceInLatmutation) __OUT_DOUBLE(DisplaceInLatmutation); + if(_UC.AutoFrac) __OUT_BOOL(AutoFrac); + line=g_strdup_printf("* CONSTRAINTS *"); + __TITLE(line); + g_free(line); + if(_UC.minVectorLength!=0.) __OUT_DOUBLE(minVectorLength); + if(_UC.IonDistances!=NULL) __OUT_TMAT_DOUBLE(IonDistances,"EndDistances",_UC._nspecies); + if(!_UC.constraint_enhancement) __OUT_BOOL(constraint_enhancement); + if(_UC.MolCenters!=NULL) __OUT_TMAT_DOUBLE(MolCenters,"EndMol",_UC._nmolecules); + line=g_strdup_printf("* CELL *"); + __TITLE(line); + g_free(line); + if(_UC.Latticevalues!=NULL){ + if(_UC._calctype_var) { + /*should be 1 line*/ + __OUT_BK_DOUBLE(Latticevalues,"Endvalues",_UC._nlatticevalues); + }else{/*more than one line if 1<_UC._nlatticevalues<=3*/ + if((_UC._nlatticevalues>1)&&(_UC._nlatticevalues<=3)) __OUT_TMAT_DOUBLE(Latticevalues,"Endvalues",_UC._nlatticevalues); + else __OUT_BK_DOUBLE(Latticevalues,"Endvalues",_UC._nlatticevalues); + } + } - fclose(vf); return 0; } @@ -1378,23 +1535,25 @@ if(job>-1){ fclose(vf);vf=NULL; /* --- READ Parameters.txt */ /* XXX XXX XXX */ - init_uspex_parameters(&(_UO.calc)); aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); - if(read_uspex_parameters(aux_file,&(_UO.calc))){ + _UO.calc=read_uspex_parameters(aux_file); + if(_UO.calc==NULL){ line = g_strdup_printf("ERROR: reading USPEX REAL Parameter.txt file!\n"); gui_text_show(ERROR, line); g_free(line); g_free(aux_file); goto uspex_fail; } - g_free(aux_file); +// g_free(aux_file); -// if(dump_uspex_parameters("out.uspex",&(_UO.calc))){ -// fprintf(stdout,"ERR: couldn't write Parameters.txt file: out.uspex\n"); -// } +/* + if(dump_uspex_parameters("out.uspex",_UO.calc)){ + fprintf(stdout,"ERR: couldn't write Parameters.txt file: out.uspex\n"); + } +*/ /* XXX XXX XXX */ - aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); +// aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); if(read_parameter_uspex(aux_file,model)!=0) { line = g_strdup_printf("ERROR: reading USPEX Parameter.txt file!\n"); gui_text_show(ERROR, line); @@ -1950,6 +2109,7 @@ gint read_frame_uspex(FILE *vf, struct model_pak *model){ vfpos=ftell(vf);/* flag */ /*_BUG_ model->cur_frame not updated, use frame title instead*/ +if(feof(vf)) return -1; line = file_read_line(vf); if(line==NULL) return -1; ptr=&(line[0]); diff --git a/src/file_uspex.h b/src/file_uspex.h index ae6faba..ca278c5 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -26,8 +26,6 @@ The GNU GPL can also be found at http://www.gnu.org #define _UO (*uspex_output) #define _UC (*uspex_calc) - - /*structures*/ typedef enum {/*released USPEX calculation methods as of 2018 (5)*/ US_CM_USPEX, /*USPEX*/ @@ -36,7 +34,6 @@ typedef enum {/*released USPEX calculation methods as of 2018 (5)*/ US_CM_PSO, /*PSO, unsupported*/ US_CM_UNKNOWN, /*reserved for future use*/ } uspex_method; - typedef enum { US_OT_ENTHALPY=1, /*most stable structure*/ US_OT_VOLUME=2, /*min volume*/ @@ -62,7 +59,6 @@ typedef enum { US_OT_PWAVE_V=1111, /*max P-wave velocity*/ US_OT_UNKNOWN=0, /*reserved for future use*/ } uspex_opt; - typedef struct { gint gen; /*generation of this individual*/ gint natoms; /*number of atoms*/ @@ -72,7 +68,6 @@ typedef struct { gdouble fitness; /*NEW: fitness*/ gdouble volume; /*total volume*/ } uspex_individual; - /* USPEX calculation structure */ typedef struct { /*additional controls*/ @@ -225,7 +220,7 @@ typedef struct { /*name*/ gchar *name; gint version; - uspex_calc_struct calc; + uspex_calc_struct *calc; /*system parameters*/ uspex_method method; gint type; @@ -261,7 +256,5 @@ typedef struct { gchar *job_path; } uspex_exec_struct; - /*methods of interest*/ - From 5f6611fe5c04db544d876cf0a4302c48f640f127 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 9 Aug 2018 20:06:42 +0900 Subject: [PATCH 19/56] gui_uspex: uspex parameters VI + valgrind debug. --- src/file_uspex.c | 271 ++++++++++++++++++++++++++++++++++++++++++----- src/file_uspex.h | 2 +- src/file_vasp.c | 3 + src/gl_graph.c | 4 +- 4 files changed, 250 insertions(+), 30 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index c26d10b..e1a909b 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -278,7 +278,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.numImages=9; _UC.numSteps=200; _UC.optReadImages=2; - _UC.optimizerType=FALSE; + _UC.optimizerType=1; _UC.optRelaxType=3; _UC.dt=0.05; _UC.ConvThreshold=0.003; @@ -346,6 +346,7 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename){ } #define __GET_STRING(value) if (find_in_string(__Q(value),line) != NULL) {\ g_free(line);line = file_read_line(vf);\ + for(i=0;i0)) j--; + ptr[j-1]='\0'; g_free(line); line = file_read_line(vf); continue; @@ -1017,7 +1027,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); __GET_INT(numImages); __GET_INT(numSteps); __GET_INT(optReadImages); - __GET_BOOL(optimizerType); + __GET_INT(optimizerType); __GET_INT(optRelaxType); __GET_DOUBLE(dt); __GET_DOUBLE(ConvThreshold); @@ -1085,28 +1095,38 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ #define __OUT_BOOL(value) do{\ if(_UC.value==1) fprintf(vf,"1\t: %s\n",__Q(value));\ else fprintf(vf,"0\t: %s\n",__Q(value));\ + is_w++;\ }while(0) #define __OUT_INT(value) do{\ fprintf(vf,"%i\t: %s\n",_UC.value,__Q(value));\ + is_w++;\ }while(0) #define __OUT_DOUBLE(value) do{\ fprintf(vf,"%.5f\t: %s\n",_UC.value,__Q(value));\ + is_w++;\ +}while(0) +#define __OUT_STRING(value) do{\ + fprintf(vf,"%s\t: %s\n",_UC.value,__Q(value));\ + is_w++;\ }while(0) /*because there is no constant logic in end_tag, we need to supply it*/ #define __OUT_BK_INT(value,end_tag,number) do{\ fprintf(vf,"%% %s\n",__Q(value));\ for(i=0;i<(number);i++) fprintf(vf,"%i ",_UC.value[i]);\ fprintf(vf,"\n");fprintf(vf,"%% %s\n",end_tag);\ + is_w++;\ }while(0) #define __OUT_BK_DOUBLE(value,end_tag,number) do{\ fprintf(vf,"%% %s\n",__Q(value));\ for(i=0;i<(number);i++) fprintf(vf,"%.5f ",_UC.value[i]);\ fprintf(vf,"\n");fprintf(vf,"%% %s\n",end_tag);\ + is_w++;\ }while(0) #define __OUT_BK_STRING(value,end_tag) do{\ fprintf(vf,"%% %s\n",__Q(value));\ - fprintf(vf,"%s\t: %s\n",_UC.value,__Q(value));\ + fprintf(vf,"%s\n",_UC.value);\ fprintf(vf,"%% %s\n",end_tag);\ + is_w++;\ }while(0) #define __OUT_TMAT_DOUBLE(value,end_tag,number) do{\ fprintf(vf,"%% %s\n",__Q(value));\ @@ -1115,11 +1135,13 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ fprintf(vf,"\n");\ }\ fprintf(vf,"%% %s\n",end_tag);\ + is_w++;\ }while(0) /**/ - FILE *vf; -// long int vfpos; + FILE *vf,*dest; + long int vfpos; + gint is_w=0; gchar *line=NULL; // gchar *ptr; // gchar c; @@ -1170,8 +1192,13 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ return -5; } /*open output*/ - vf = fopen(filename, "w"); - if (!vf) return -2; + dest = fopen(filename, "w"); + if (!dest) return -2; + vf = tmpfile(); + if(!vf) { + fclose(dest); + return -3; + } /*output resulting "Parameter.txt" input*/ fprintf(vf,"PARAMETERS EVOLUTIONARY ALGORITHM\n"); fprintf(vf,"GENERATED BY GDIS %4.2f.%d (C) %d\n",VERSION,PATCH,YEAR); @@ -1203,26 +1230,48 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ __OUT_INT(calculationType); __OUT_INT(optType); __OUT_BK_INT(atomType,"EndAtomType",_UC._nspecies); - __OUT_BK_INT(numSpecies,"EndNumSpecies",_UC._var_nspecies); - __OUT_DOUBLE(ExternalPressure); + if(_UC._var_nspecies==1){ + __OUT_BK_INT(numSpecies,"EndNumSpecies",_UC._nspecies); + is_w++; + }else{ + fprintf(vf,"%% numSpecies\n"); + for(i=0;i<_UC._var_nspecies;i++){ + for(j=0;j<_UC._nspecies;j++){ + fprintf(vf,"%i ",_UC.numSpecies[j+i*_UC._nspecies]); + } + fprintf(vf,"\n"); + } + fprintf(vf,"%% EndNumSpecies\n"); + is_w++; + } + if(_UC.calculationMethod==US_CM_META) __OUT_DOUBLE(ExternalPressure); + if(_UC.ExternalPressure!=0.) __OUT_DOUBLE(ExternalPressure); /*print when NOT default or unset*/ if(_UC.valences!=NULL) __OUT_BK_INT(valences,"endValences",_UC._nspecies); if(_UC.goodBonds!=NULL) __OUT_TMAT_DOUBLE(goodBonds,"EndGoodBonds",_UC._nspecies);/*TODO: use of a single value is unsupported*/ if(!_UC.checkMolecules) __OUT_BOOL(checkMolecules); if(_UC.checkConnectivity) __OUT_BOOL(checkConnectivity); +vfpos=ftell(vf);/* flag */ +is_w=0; line=g_strdup_printf("* POPULATION *"); __TITLE(line); g_free(line); if(_UC.populationSize!=0) __OUT_INT(populationSize); - if(_UC.initialPopSize!=0) __OUT_INT(initialPopSize); + if((_UC.initialPopSize!=0)&&(_UC.initialPopSize!=_UC.populationSize)) __OUT_INT(initialPopSize); if(_UC.numGenerations!=100) __OUT_INT(numGenerations); if(_UC.stopCrit!=0) __OUT_INT(stopCrit); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; line=g_strdup_printf("* SURVIVAL OF THE FITTEST & SELECTION *"); __TITLE(line); g_free(line); if(_UC.bestFrac!=0.7) __OUT_DOUBLE(bestFrac); if(_UC.keepBestHM!=0) __OUT_INT(keepBestHM); if(_UC.reoptOld) __OUT_BOOL(reoptOld); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; line=g_strdup_printf("* STRUCTURE GENERATION & VARIATION OPERATORS *"); __TITLE(line); g_free(line); @@ -1246,8 +1295,11 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ if(_UC.specificSwaps!=NULL) __OUT_BK_STRING(specificSwaps,"EndSpecific"); if(_UC.mutationDegree!=0.) __OUT_DOUBLE(mutationDegree); if(_UC.mutationRate!=0.5) __OUT_DOUBLE(mutationRate); - if(_UC.DisplaceInLatmutation) __OUT_DOUBLE(DisplaceInLatmutation); + if(_UC.DisplaceInLatmutation!=1.0) __OUT_DOUBLE(DisplaceInLatmutation); if(_UC.AutoFrac) __OUT_BOOL(AutoFrac); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; line=g_strdup_printf("* CONSTRAINTS *"); __TITLE(line); g_free(line); @@ -1255,6 +1307,9 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ if(_UC.IonDistances!=NULL) __OUT_TMAT_DOUBLE(IonDistances,"EndDistances",_UC._nspecies); if(!_UC.constraint_enhancement) __OUT_BOOL(constraint_enhancement); if(_UC.MolCenters!=NULL) __OUT_TMAT_DOUBLE(MolCenters,"EndMol",_UC._nmolecules); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; line=g_strdup_printf("* CELL *"); __TITLE(line); g_free(line); @@ -1267,8 +1322,161 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ else __OUT_BK_DOUBLE(Latticevalues,"Endvalues",_UC._nlatticevalues); } } - + if(_UC.splitInto!=NULL) __OUT_BK_INT(splitInto,"EndSplitInto",_UC._nsplits); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* AB INITIO CALCULATION *"); + __TITLE(line); + g_free(line); + if(_UC.abinitioCode!=NULL) __OUT_BK_INT(abinitioCode,"ENDabinit",_UC._num_opt_steps); + if(_UC.KresolStart!=NULL) __OUT_BK_DOUBLE(KresolStart,"Kresolend",_UC._num_opt_steps); + if(_UC.vacuumSize!=NULL) __OUT_BK_DOUBLE(vacuumSize,"endVacuumSize",_UC._num_opt_steps); + if(_UC.numParallelCalcs!=1) __OUT_INT(numParallelCalcs); + __OUT_BK_STRING(commandExecutable,"EndExecutable");/*mandatory block*/ + if(_UC.whichCluster!=0) __OUT_INT(whichCluster); + if((_UC.whichCluster==2)&&(_UC.remoteFolder!=NULL)) __OUT_STRING(remoteFolder); + if(_UC.PhaseDiagram) __OUT_BOOL(PhaseDiagram); +/*note that mandatory block will always make is_w>0*/ +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* FINGERPRINT SETTINGS *"); + __TITLE(line); + g_free(line); + if(_UC.RmaxFing!=10.) __OUT_DOUBLE(RmaxFing); + if(_UC.deltaFing!=0.08) __OUT_DOUBLE(deltaFing); + if(_UC.sigmaFing!=0.03) __OUT_DOUBLE(sigmaFing); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* ANTISEEDS SETTINGS *"); + __TITLE(line); + g_free(line); + if(_UC.antiSeedsActivation!=5000) __OUT_INT(antiSeedsActivation); + if(_UC.antiSeedsMax!=0.) __OUT_DOUBLE(antiSeedsMax); + if(_UC.antiSeedsSigma!=0.001) __OUT_DOUBLE(antiSeedsSigma); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* SPACE GROUP DETERMINATION *"); + __TITLE(line); + g_free(line); + if((_UC._calctype_dim==3)&&(!_UC.doSpaceGroup)) __OUT_BOOL(doSpaceGroup); + if((_UC._calctype_dim!=3)&&(_UC.doSpaceGroup)) __OUT_BOOL(doSpaceGroup); + if(_UC.SymTolerance!=0.1) __OUT_DOUBLE(SymTolerance); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* DEVELOPERS *"); + __TITLE(line); + g_free(line); + if(_UC.repeatForStatistics!=1) { + __OUT_INT(repeatForStatistics); + if(_UC.stopFitness!=0.) __OUT_DOUBLE(stopFitness); + } + if(_UC.collectForces) __OUT_BOOL(collectForces); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* SELDOM *"); + __TITLE(line); + g_free(line); + if(!_UC.ordering_active) __OUT_BOOL(ordering_active); + if(_UC.symmetrize) __OUT_BOOL(symmetrize); + if(_UC.valenceElectr!=NULL) __OUT_BK_INT(valenceElectr,"endValenceElectr",_UC._nspecies); + if(_UC.percSliceShift!=1.0) __OUT_DOUBLE(percSliceShift); + if(_UC.dynamicalBestHM!=2) __OUT_INT(dynamicalBestHM); + if(_UC.softMutOnly!=NULL) __OUT_BK_STRING(softMutOnly,"EndSoftOnly"); + if(_UC.maxDistHeredity!=0.5) __OUT_DOUBLE(maxDistHeredity); + if(_UC.manyParents!=0) __OUT_INT(manyParents); + if(_UC.minSlice!=0.) __OUT_DOUBLE(minSlice); + if(_UC.maxSlice!=0.) __OUT_DOUBLE(maxSlice); + if(_UC.numberparents!=2) __OUT_INT(numberparents); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* SURFACES *"); + __TITLE(line); + g_free(line); + if(_UC.thicknessS!=2.0) __OUT_DOUBLE(thicknessS); + if(_UC.thicknessB!=3.0) __OUT_DOUBLE(thicknessB); + if(_UC.reconstruct!=1) __OUT_INT(reconstruct); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* VARIABLE COMPOSITION *"); + __TITLE(line); + g_free(line); + if(_UC.firstGeneMax!=11) __OUT_INT(firstGeneMax); + if(_UC._calctype_var){/*mandatory if varcomp*/ + __OUT_INT(minAt); + __OUT_INT(maxAt); + } + if(_UC.fracTrans!=0.1) __OUT_DOUBLE(fracTrans); + if(_UC.howManyTrans!=0.2) __OUT_DOUBLE(howManyTrans); + if(_UC.specificTrans!=NULL) __OUT_BK_INT(specificTrans,"EndTransSpecific",_UC._nspetrans); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* METADYNAMICS *"); + __TITLE(line); + g_free(line); + if(_UC.GaussianWidth!=0.) __OUT_DOUBLE(GaussianWidth); + if(_UC.GaussianHeight!=0.) __OUT_DOUBLE(GaussianHeight); + if(_UC.FullRelax!=2) __OUT_INT(FullRelax); + if(_UC.maxVectorLength!=0.) __OUT_DOUBLE(maxVectorLength); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* PARTICLE SWARM OPTIMIZATION *"); + __TITLE(line); + g_free(line); + if(_UC.PSO_softMut!=1.) __OUT_DOUBLE(PSO_softMut); + if(_UC.PSO_BestStruc!=1.) __OUT_DOUBLE(PSO_BestStruc); + if(_UC.PSO_BestEver!=1.) __OUT_DOUBLE(PSO_BestEver); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* VCNEB *"); + if(_UC.vcnebType!=110) __OUT_INT(vcnebType); + if(_UC.numImages!=9) __OUT_INT(numImages); + if(_UC.numSteps!=200) __OUT_INT(numSteps); + if(_UC.optReadImages!=2) __OUT_INT(optReadImages); + if((_UC._vcnebtype_method==1)&&(_UC.optimizerType!=1)) __OUT_INT(optimizerType); + if((_UC._vcnebtype_method==2)&&(_UC.optimizerType!=2)) __OUT_INT(optimizerType); + if(_UC.optRelaxType!=3) __OUT_INT(optRelaxType); + if(_UC.dt!=0.05) __OUT_DOUBLE(dt); + if(_UC.ConvThreshold!=0.003) __OUT_DOUBLE(ConvThreshold); + if(_UC.VarPathLength!=0.) __OUT_DOUBLE(VarPathLength); + if(_UC.K_min!=5.) __OUT_DOUBLE(K_min); + if(_UC.K_max!=5.) __OUT_DOUBLE(K_max); + if(_UC.Kconstant!=5.) __OUT_DOUBLE(Kconstant); + if(_UC.optFreezing) __OUT_BOOL(optFreezing); + if(_UC.optMethodCIDI!=0) __OUT_INT(optMethodCIDI); + if(_UC.startCIDIStep!=100) __OUT_INT(startCIDIStep); + if(_UC.pickupImages!=NULL) __OUT_BK_INT(pickupImages,"EndPickupImages",_UC._npickimg); + if(_UC.FormatType!=2) __OUT_INT(FormatType); + if(_UC.PrintStep!=1) __OUT_INT(PrintStep); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ + line=g_strdup_printf("* END OF FILE *"); + __TITLE(line); + g_free(line); + fprintf(vf,"EOFEOFEOF\n"); + /*remove the garbage after EOFEOFEOF*/ + rewind(vf); + line = file_read_line(vf); + while(line){ + if(find_in_string("EOFEOFEOF",line) != NULL) break; + fprintf(dest,"%s",line); + g_free(line); + line = file_read_line(vf); + } + if(line) g_free(line); + /*there might be some garbage on the file after this point*/ fclose(vf); + fclose(dest); return 0; } @@ -1342,7 +1550,7 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ if(!e_red) _UO.min_E/=(gdouble)_UO.ind[0].natoms; _UO.max_E=_UO.min_E; idx=0;_UO.num_gen=1; - while (line){ + while(line){ if(_UO.have_fitness){ sscanf(line," %i %i%*[^[][%[^]]] %lf %lf %*f %lf %*s", &(_UO.ind[idx].gen),&(red_index),&(tmp[0]),&(_UO.ind[idx].energy),&(_UO.ind[idx].volume),&(_UO.ind[idx].fitness)); @@ -1352,7 +1560,8 @@ if(_UO.have_fitness){ &(_UO.ind[idx].gen),&(red_index),&(tmp[0]),&(_UO.ind[idx].energy),&(_UO.ind[idx].volume)); if(_UO.ind[idx].gen<_UO.num_gen) _UO.ind[idx].gen++; if(_UO.ind[idx].gen>_UO.num_gen) _UO.num_gen=_UO.ind[idx].gen; - _UO.red_index[red_index]=idx; +/*_VALGRIND_BUG_: _UO.red_index[red_index]=idx;*/ + _UO.red_index[red_index-1]=idx; if(!e_red) _UO.ind[idx].E=_UO.ind[idx].energy/_UO.ind[idx].natoms; else _UO.ind[idx].E=_UO.ind[idx].energy; #if DEBUG_USPEX_READ @@ -1376,6 +1585,7 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ gchar *ptr2; gchar *res_folder; gchar *aux_file; + gint probe;/*valgrind check*/ gint ix; gint idx; gint jdx; @@ -1545,13 +1755,11 @@ if(job>-1){ goto uspex_fail; } // g_free(aux_file); - /* if(dump_uspex_parameters("out.uspex",_UO.calc)){ fprintf(stdout,"ERR: couldn't write Parameters.txt file: out.uspex\n"); } */ - /* XXX XXX XXX */ // aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); if(read_parameter_uspex(aux_file,model)!=0) { @@ -1574,6 +1782,7 @@ if(job>-1){ if(_UO.nspecies==0) _UO.nspecies=num; if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ /* --- if calculationMethod={USPEX,META} */ + g_free(model->basename);/*FIX: _VALGRIND_BUG_*/ model->basename=g_strdup_printf("uspex"); /* we have to open structure file first because of inconsistency in atom reporting in Individuals file*/ /* --- READ gatheredPOSCARS <- this is going to be the main model file */ @@ -1667,9 +1876,11 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ ptr=&(line[0]); ptr2=ptr;jdx=0; do{/*get the number of each species (in the Parameters.txt order)*/ - _UO.ind[ix].atoms[jdx]=g_ascii_strtod(ptr,&ptr2); - _UO.ind[ix].natoms+=_UO.ind[ix].atoms[jdx]; +/*_VALGRIND_BUG_: _UO.ind[ix].atoms[jdx]=g_ascii_strtod(ptr,&ptr2);*/ + probe=g_ascii_strtod(ptr,&ptr2); if(ptr2==ptr) break; + _UO.ind[ix].atoms[jdx]=probe; + _UO.ind[ix].natoms+=_UO.ind[ix].atoms[jdx]; jdx++; ptr=ptr2; }while(1); @@ -1707,15 +1918,17 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ if(_UO.method==US_CM_META) { aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); vf = fopen(aux_file, "rt"); - if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); - else { + if (!vf) { + g_free(aux_file); + aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); + } else { fclose(vf); vf=NULL; } }else{ aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); } - vf = fopen(aux_file, "rt"); + vf = fopen(aux_file, "rt");g_free(aux_file); if (!vf) {/*very unlikely, we just opened it*/ if(_UO.ind!=NULL) g_free(_UO.ind); line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS file!\n"); @@ -1758,6 +1971,7 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ } num++; ix++; + if(ix>=_UO.num_struct) break;/*FIX _VALGRIND_BUG_*/ } e=g_malloc((1+num)*sizeof(gdouble)); ix=skip; @@ -1765,6 +1979,7 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ while(_UO.ind[ix].gen==gen){ e[ix-skip+1]=_UO.ind[ix].E; ix++; + if(ix>=_UO.num_struct) break;/*FIX _VALGRIND_BUG_*/ } graph_add_borned_data( _UO.num_gen,e,0,_UO.num_gen, @@ -2087,8 +2302,10 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i g_free(line); goto uspex_fail; } + /*g_free some data*/ + g_free(res_folder); - + /*end*/ error_table_print_all(); return 0; uspex_fail: @@ -2109,19 +2326,19 @@ gint read_frame_uspex(FILE *vf, struct model_pak *model){ vfpos=ftell(vf);/* flag */ /*_BUG_ model->cur_frame not updated, use frame title instead*/ -if(feof(vf)) return -1; line = file_read_line(vf); if(line==NULL) return -1; ptr=&(line[0]); while(g_ascii_isalpha(*ptr)) ptr++; sscanf(ptr,"%i%*s",&idx); +g_free(line);/*FIX: _VALGRIND_BUG_*/ fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ if(vasp_load_poscar5(vf,model)<0) return 3; /* in case of meta idx is *not* the real number of the structure */ /* now the index should always be _UO.red_index[idx-1] <- I THINK*/ - line=g_strdup_printf("%lf eV",_UO.ind[_UO.red_index[idx]].energy); + line=g_strdup_printf("%lf eV",_UO.ind[_UO.red_index[idx-1]].energy); property_add_ranked(3, "Energy", line, model); - model->volume=_UO.ind[_UO.red_index[idx]].volume; + model->volume=_UO.ind[_UO.red_index[idx-1]].volume; g_free(line); line=g_strdup_printf("%i",idx); property_add_ranked(8, "Structure", line, model); diff --git a/src/file_uspex.h b/src/file_uspex.h index ca278c5..bdb259b 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -197,7 +197,7 @@ typedef struct { gint numImages; /*initial number of images*/ gint numSteps; /*maximum VC-NEB steps*/ gint optReadImages; /*reading the Image file (all image, initial and final, or +intermediate)*/ - gboolean optimizerType; /*optimization algorithm*/ + gint optimizerType; /*optimization algorithm*/ gint optRelaxType; /*relaxation mode (fixed cell, only cell, full relaxation)*/ gdouble dt; /*time step*/ gdouble ConvThreshold; /*halting RMS (eV/Ang) condition*/ diff --git a/src/file_vasp.c b/src/file_vasp.c index 19a9f48..0bccaea 100644 --- a/src/file_vasp.c +++ b/src/file_vasp.c @@ -1835,7 +1835,10 @@ core_delete_all(model); name=g_strdup(spec); model->num_atoms+=ix; }while(1); + g_free(spec);/*FIX _VALGRIND_BUG_*/ + g_free(label);/*FIX _VALGRIND_BUG_*/ property_add_ranked(7, "Formula", name, model); + g_free(name);/*FIX _VALGRIND_BUG_*/ g_free(line); /*Always true in VASP*/ model->fractional=TRUE; diff --git a/src/gl_graph.c b/src/gl_graph.c index 3f64e0c..c9586ff 100644 --- a/src/gl_graph.c +++ b/src/gl_graph.c @@ -293,8 +293,8 @@ else } if((type==GRAPH_USPEX)||(type==GRAPH_USPEX_BEST)){ -ptr = g_malloc(1+((gint)x[0])*sizeof(gdouble)); -memcpy(ptr,x,(1+(gint)x[0])*sizeof(gdouble)); +ptr = g_malloc((1+(gint)x[0])*sizeof(gdouble));/*_VALGRIND_BUG_ (misplaced parenthesis)*/ +memcpy(ptr,&(x[0]),(1+(gint)x[0])*sizeof(gdouble)); }else{ ptr = g_malloc(size*sizeof(gdouble)); memcpy(ptr, x, size*sizeof(gdouble)); From c8d3c35718cc6d2ed3cfcdfaa46a0264b22f529e Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 10 Aug 2018 16:05:29 +0900 Subject: [PATCH 20/56] gui_uspex: uspex parameters VII. --- src/file_uspex.c | 224 ++++++++++++----------------------------------- src/file_uspex.h | 8 +- src/gl_graph.c | 8 +- 3 files changed, 63 insertions(+), 177 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index e1a909b..9b177ae 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -59,129 +59,11 @@ extern struct elem_pak elements[]; #define DEBUG_USPEX_READ 0 -gint read_parameter_uspex(gchar *filename, struct model_pak *model){ - FILE *vf; - gchar *line=NULL; - gchar *ptr; - gint idx; - uspex_output_struct *uspex_output=model->uspex; - /* specific */ - gchar method; - /*start*/ - _UO.nspecies=0; - vf = fopen(filename, "rt"); - if (!vf) return 1; - line = file_read_line(vf); - while (line){ - if (find_in_string("calculationMethod",line) != NULL) { - sscanf(line,"%c%*s : calculationMethod %*s",&(method)); - switch (method){ - case 'U': - case 'u': - /*uspex*/ - _UO.method=US_CM_USPEX; - property_add_ranked(2, "Calculation", "USPEX", model); -#if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX calculationMethod=USPEX\n"); -#endif - break; - case 'M': - case 'm': - /*metadynamics*/ - _UO.method=US_CM_META; -#if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX calculationMethod=META\n"); -#endif - break; - case 'V': - case 'v': - /*variable cell nudged elastic band*/ - _UO.method=US_CM_VCNEB; -#if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX calculationMethod=VCNEB\n"); -#endif - break; - case 'P': - case 'p': - /*particle swarm optimization*/ - _UO.method=US_CM_PSO; -#if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX calculationMethod=PSO\n"); -#endif - break; - default: - g_free(line); - line = g_strdup_printf("ERROR: unsupported USPEX method!\n"); - gui_text_show(ERROR, line); - g_free(line); - return 1; - } - } - if (find_in_string("calculationType",line) != NULL) { - sscanf(line,"%i : calculationType %*s",&(_UO.type)); -#if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX calculationType=%i\n",_UO.type); -#endif - } - if (find_in_string("optType",line) != NULL) { - sscanf(line,"%i : optType %*s",&(_UO.opt_type)); -#if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX optType=%i\n",_UO.type); -#endif - - } - if (find_in_string("atomType",line) !=NULL){ - /*let's count number of species here*/ - g_free(line); - line = file_read_line(vf); - ptr=&(line[0]); - while(*ptr==' ') ptr++;/*skip initial space (if any)*/ - _UO.nspecies=1;/*there is at least one species*/ - while(*ptr!='\0'){ - if(*ptr==' ') { - _UO.nspecies++;ptr++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ - }else ptr++; - } -#if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX number_of_species=%i\n",_UO.nspecies); -#endif - /*now let's find each species symbol*/ - _UO.spe_Z=g_malloc(_UO.nspecies*sizeof(gint)); - ptr=&(line[0]);idx=0; - while(*ptr==' ') ptr++;/*skip initial space (if any)*/ - while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - if(g_ascii_isdigit(*ptr)) _UO.spe_Z[idx]=g_ascii_strtod(ptr,NULL);/*user provided Z number*/ - else _UO.spe_Z[idx]=elem_symbol_test(ptr);/*user provided symbol*/ - if((_UO.spe_Z[idx]<=0)||(_UO.spe_Z[idx]>MAX_ELEMENTS-1)){/*X not allowed*/ - g_free(line); - line = g_strdup_printf("ERROR: USPEX Parameters.txt file contain invalid atom definition!\n"); - gui_text_show(ERROR, line); - g_free(line); - return -1; - } -#if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX species[%i] Z=%i\n",idx,_UO.spe_Z[idx]); -#endif - ptr++;idx++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ - } - } - g_free(line); - line = file_read_line(vf); - } -/*other parameters will be filled later for gui_uspex */ - - - -/*end of Parameters.txt read*/ - fclose(vf); - return 0; -} +/***********************************/ +/* Initialize uspex_calc structure */ +/***********************************/ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ - /*init an (assumed) empty structure with default parameters*/ - /* Contrary to USPEX defaults, init default are just to prepare the calc structure. */ + /*Initialize uspex_calc with model independant parameters.*/ _UC.name=NULL; _UC.special=0; _UC.calculationMethod=US_CM_USPEX; @@ -295,7 +177,6 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ } /************************************************************************/ /* Read Parameters.txt and fill keywords of uspex_calc_struct structure */ -/*For reading Parameters.txt files, *not* preparing a model for display.*/ /************************************************************************/ uspex_calc_struct *read_uspex_parameters(gchar *filename){ FILE *vf; @@ -1083,7 +964,9 @@ fprintf(stdout,"#DBG: PROBE FAIL LINE: %s",line); #undef __GET_CHARS #undef __NSPECIES } - +/*****************************************/ +/* OUTPUT a minimal uspex parameter file */ +/*****************************************/ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ #define __TITLE(caption) do{\ gchar *tmp=g_strnfill (strlen(caption),'*');\ @@ -1143,8 +1026,6 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ long int vfpos; gint is_w=0; gchar *line=NULL; -// gchar *ptr; -// gchar c; gint i,j;//,k; /*tests*/ if(filename==NULL) return -1; @@ -1478,9 +1359,19 @@ else vfpos=ftell(vf);/* flag */ fclose(vf); fclose(dest); return 0; +#undef __TITLE +#undef __OUT_BOOL +#undef __OUT_INT +#undef __OUT_DOUBLE +#undef __OUT_STRING +#undef __OUT_BK_INT +#undef __OUT_BK_DOUBLE +#undef __OUT_BK_STRING +#undef __OUT_TMAT_DOUBLE } - - +/*******************************/ +/* Read Individual format file */ +/*******************************/ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ FILE *vf; long int vfpos; @@ -1524,7 +1415,7 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ /* META calculation have a gen=0 Individual unfortunately, it is *not* in the gather- -POSCARS file, so we ignore gen=0 for now. */ - if(_UO.method==US_CM_META){ + if(_UO.calc->calculationMethod==US_CM_META){ g_free(line); line = file_read_line(vf); vfpos=ftell(vf);/* flag */ @@ -1576,7 +1467,10 @@ fprintf(stdout,"#DBG: USPEX[Individual]: GEN=%i STRUCT=%i e=%lf n_atom=%i E=%lf\ /*all done*/ return 0; } - +/**********************************************************************************/ +/* Read uspex output */ +/* Require several files: OUTPUT.txt, Parameters.txt + calculation specific files.*/ +/**********************************************************************************/ gint read_output_uspex(gchar *filename, struct model_pak *model){ gchar *line; FILE *vf; @@ -1610,6 +1504,7 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ gdouble max_E; gchar *atoms; uspex_output_struct *uspex_output; + uspex_calc_struct *uspex_calc; /* checks */ g_return_val_if_fail(model != NULL, 1); g_return_val_if_fail(filename != NULL, 2); @@ -1744,7 +1639,6 @@ if(job>-1){ /* --- and close */ fclose(vf);vf=NULL; /* --- READ Parameters.txt */ -/* XXX XXX XXX */ aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); _UO.calc=read_uspex_parameters(aux_file); if(_UO.calc==NULL){ @@ -1754,40 +1648,33 @@ if(job>-1){ g_free(aux_file); goto uspex_fail; } -// g_free(aux_file); + g_free(aux_file); + uspex_calc=_UO.calc; + /* if(dump_uspex_parameters("out.uspex",_UO.calc)){ fprintf(stdout,"ERR: couldn't write Parameters.txt file: out.uspex\n"); } */ -/* XXX XXX XXX */ -// aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); - if(read_parameter_uspex(aux_file,model)!=0) { - line = g_strdup_printf("ERROR: reading USPEX Parameter.txt file!\n"); - gui_text_show(ERROR, line); - g_free(line); - goto uspex_fail; - } /* --- CHECK type from Parameters.txt matches that of OUTPUT.TXT */ - if((job!=-1)&&(job!=_UO.type)){ + if((job!=-1)&&(job!=_UC.calculationType)){ /*since VCNEB will fail here due to a non-unified OUTPUT.txt format *we need to be a little more permissive... */ - line = g_strdup_printf("ERROR: inconsistent USPEX files (%i!=%i)!\n",job,_UO.type); + line = g_strdup_printf("ERROR: inconsistent USPEX files (%i!=%i)!\n",job,_UC.calculationType); gui_text_show(ERROR, line); g_free(line); goto uspex_fail; } - g_free(aux_file); /*special case: no nspecies information*/ - if(_UO.nspecies==0) _UO.nspecies=num; -if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ + if(_UC._nspecies==0) _UC._nspecies=num; +if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ /* --- if calculationMethod={USPEX,META} */ g_free(model->basename);/*FIX: _VALGRIND_BUG_*/ model->basename=g_strdup_printf("uspex"); /* we have to open structure file first because of inconsistency in atom reporting in Individuals file*/ /* --- READ gatheredPOSCARS <- this is going to be the main model file */ /* ^^^ META: If gatheredPOSCARS_relaxed exists, read it instead */ - if(_UO.method==US_CM_META) { + if(_UC.calculationMethod==US_CM_META) { aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); @@ -1830,8 +1717,8 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ line = file_read_line(vf); } if(idx==5){/*calculate number of species and atoms*/ - _UO.ind[ix].atoms=g_malloc(_UO.nspecies*sizeof(gint)); - for(jdx=0;jdx<_UO.nspecies;jdx++) _UO.ind[ix].atoms[jdx]=0;/*init atoms*/ + _UO.ind[ix].atoms=g_malloc(_UC._nspecies*sizeof(gint)); + for(jdx=0;jdx<_UC._nspecies;jdx++) _UO.ind[ix].atoms[jdx]=0;/*init atoms*/ _UO.ind[ix].natoms=0; /*get this structure nspecies*/ ptr=&(line[0]); @@ -1843,7 +1730,7 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ while(*ptr==' ') ptr++;/*skip space*/ }else ptr++; } - if(jdx<_UO.nspecies){ + if(jdx<_UC._nspecies){ gchar *line2;/*double buffer*/ /*we need to know which species is here*/ line2 = file_read_line(vf); @@ -1856,7 +1743,7 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ while((*ptr!='\0')&&(*ptr2!='\0')){ /*get the correct jdx number*/ jdx=0;/*we reset jdx to cope with 'OUT OF ORDER' poscar species, if any*/ - while((jdx<_UO.nspecies)&&(_UO.spe_Z[jdx]!=elem_symbol_test(ptr))) jdx++; + while((jdx<_UC._nspecies)&&(_UC.atomType[jdx]!=elem_symbol_test(ptr))) jdx++; _UO.ind[ix].atoms[jdx]=g_ascii_strtod(ptr2,NULL); _UO.ind[ix].natoms+=_UO.ind[ix].atoms[jdx]; ptr++;ptr2++; @@ -1891,12 +1778,12 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ g_free(line); line = file_read_line(vf); } - strcpy(model->filename,aux_file);// which means that we "forget" about OUTPUT.txt + strcpy(model->filename,aux_file);// which means that we "forget" about OUTPUT.txt g_free(aux_file); - + fclose(vf); /* --- READ Individuals <- information about all structures */ /* ^^^ META: If Individuals_relaxed exists, read it instead */ - if(_UO.method==US_CM_META) { + if(_UC.calculationMethod==US_CM_META) { aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); @@ -1915,7 +1802,7 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ } g_free(aux_file); /* --- open the last frame */ - if(_UO.method==US_CM_META) { + if(_UC.calculationMethod==US_CM_META) { aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) { @@ -2000,7 +1887,7 @@ if((_UO.method==US_CM_USPEX)||(_UO.method==US_CM_META)){ fprintf(stdout,"#DBG: USPEX_BEST: GEN=%i STRUCT=%i E=%lf\n",gen+1,1+_UO.best_ind[gen+1],e[gen+1]); #endif } - if(_UO.method==US_CM_META) {/*shift best_ind by 1*/ + if(_UC.calculationMethod==US_CM_META) {/*shift best_ind by 1*/ for(gen=1;gen<=_UO.num_gen;gen++) _UO.best_ind[gen]++; } graph_add_borned_data( @@ -2018,10 +1905,10 @@ fprintf(stdout,"#DBG: USPEX_BEST: GEN=%i STRUCT=%i E=%lf\n",gen+1,1+_UO.best_ind /* --- variable composition */ if(_UO.var){ /* --- NEW: add a simple composition % graph for each species */ -if(_UO.nspecies>1){ +if(_UC._nspecies>1){ n_compo=2; ix=0; -for(species_index=0;species_index<_UO.nspecies;species_index++){ +for(species_index=0;species_index<_UC._nspecies;species_index++){ c=g_malloc(2*sizeof(gdouble));/*suppose at least 2 different compositions*/ c[0]=(gdouble)_UO.ind[0].atoms[species_index] / (gdouble)_UO.ind[0].natoms; c[1]=c[0]; @@ -2093,7 +1980,7 @@ for(species_index=0;species_index<_UO.nspecies;species_index++){ } } /* prepare composition diagram*/ - line=g_strdup_printf("COMP_%s",elements[_UO.spe_Z[species_index]].symbol); + line=g_strdup_printf("COMP_%s",elements[_UC.atomType[species_index]].symbol); _UO.graph_comp=graph_new(line, model); graph_add_borned_data( n_compo,tag,0,1,_UO.min_E-(max_E-_UO.min_E)*0.05,max_E+(max_E-_UO.min_E)*0.05,GRAPH_USPEX_2D,_UO.graph_comp); @@ -2122,14 +2009,14 @@ for(species_index=0;species_index<_UO.nspecies;species_index++){ model_prep(model); -}else if(_UO.method==US_CM_VCNEB){ +}else if(_UC.calculationMethod==US_CM_VCNEB){ /* --- tentative at adding VCNEB, which format is different**/ /* ^^^ *BUT unfortunately, we NEED a vasp5 output (VCNEB stayed at VASP4) */ /* thus we create a new file called transitionPath_POSCARs5 which is a * translation of transitionPath_POSCARs for VASP5...*/ - atoms = g_strdup_printf("%s",elements[_UO.spe_Z[0]].symbol); - for(idx=1;idx<_UO.nspecies;idx++){ - line = g_strdup_printf("%s %s",atoms,elements[_UO.spe_Z[idx]].symbol); + atoms = g_strdup_printf("%s",elements[_UC.atomType[0]].symbol); + for(idx=1;idx<_UC._nspecies;idx++){ + line = g_strdup_printf("%s %s",atoms,elements[_UC.atomType[idx]].symbol); g_free(atoms); atoms=line; } @@ -2146,7 +2033,6 @@ for(species_index=0;species_index<_UO.nspecies;species_index++){ aux_file = g_strdup_printf("%s%s",res_folder,"transitionPath_POSCARs5"); f_dest = fopen(aux_file, "w"); if(!f_dest) { - vf=f_src; line = g_strdup_printf("ERROR: can't WRITE into USPEX transitionPath_POSCARs5 file!\n"); gui_text_show(ERROR, line); g_free(line); @@ -2185,7 +2071,6 @@ fprintf(stdout,"#DBG: USPEX[VCNEB]: NATOMS=%i ATOMS=%s\n",natoms,atoms); } fclose(f_src); fclose(f_dest); - fclose(vf);vf=NULL; g_free(atoms); _UO.ind=g_malloc((_UO.num_struct)*sizeof(uspex_individual)); /* --- read energies from the Energy file */ @@ -2220,7 +2105,7 @@ fprintf(stdout,"#DBG: USPEX[VCNEB]: NATOMS=%i ATOMS=%s\n",natoms,atoms); for(idx=0;idx<_UO.num_struct;idx++){ if(!line) break;/*<- useful? */ sscanf(line," %*i %lf %*s",&(_UO.ind[idx].energy)); - _UO.ind[idx].atoms=g_malloc(_UO.nspecies*sizeof(gint)); + _UO.ind[idx].atoms=g_malloc(_UC._nspecies*sizeof(gint)); _UO.ind[idx].natoms=natoms;/*<-constant*/ _UO.ind[idx].E = _UO.ind[idx].energy / (gdouble)_UO.ind[idx].natoms; _UO.ind[idx].gen=idx;/*<- this is actually *not* true*/ @@ -2312,7 +2197,6 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i line = g_strdup_printf("ERROR: loading USPEX failed!\n"); gui_text_show(ERROR, line); g_free(line); - if(vf!=NULL) fclose(vf); return 3; } gint read_frame_uspex(FILE *vf, struct model_pak *model){ @@ -2339,10 +2223,18 @@ fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ line=g_strdup_printf("%lf eV",_UO.ind[_UO.red_index[idx-1]].energy); property_add_ranked(3, "Energy", line, model); model->volume=_UO.ind[_UO.red_index[idx-1]].volume; + g_free(line);line=g_strdup_printf("%lf uV",model->volume); + property_add_ranked(4, "Volume", line, model); g_free(line); + /*note: Formula property rank is 7*/ line=g_strdup_printf("%i",idx); property_add_ranked(8, "Structure", line, model); g_free(line); +if(_UO.have_fitness){ + line=g_strdup_printf("%f f",_UO.ind[_UO.red_index[idx-1]].fitness); + property_add_ranked(9, "Fitness", line, model); + g_free(line); +} return 0; } diff --git a/src/file_uspex.h b/src/file_uspex.h index bdb259b..17dd60c 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -221,21 +221,15 @@ typedef struct { gchar *name; gint version; uspex_calc_struct *calc; -/*system parameters*/ - uspex_method method; - gint type; - /* in detail */ + /* details */ gint dim; gboolean mol; gboolean var; /* optimization */ - gint opt_type; gboolean have_fitness; /*structures*/ gint num_gen; gint num_struct; - gint nspecies; /*number of species*/ - gint *spe_Z; /*atomic number of each species*/ gint *red_index; /*in case not all structure are displayed (ie. META)*/ gdouble min_E; gdouble max_E; diff --git a/src/gl_graph.c b/src/gl_graph.c index c9586ff..49eec9b 100644 --- a/src/gl_graph.c +++ b/src/gl_graph.c @@ -396,7 +396,7 @@ yy = (gint) yf; yy *= -1; yy += oy; if((y>yy-3)&&(yuspex; + uspex_output_struct *uspex_output=model->uspex; /*we have a hit*/ graph->select=struct_sel; graph->select_2=ptr[i]; @@ -404,7 +404,7 @@ if((y>yy-3)&&(yselect_label=g_strdup_printf("[%i,%f]",struct_sel+1,ptr[i]); vf=fopen(model->filename, "r"); if(!vf) return; - model->cur_frame=(*uspex_calc).best_ind[struct_sel+1];/*this is the structure number*/ + model->cur_frame=(*uspex_output).best_ind[struct_sel+1];/*this is the structure number*/ read_raw_frame(vf,model->cur_frame,model); fclose(vf); tree_model_refresh(model); @@ -434,7 +434,7 @@ for (list=graph->set_list ; list ; list=g_slist_next(list)) yy *= -1; yy += oy; if((y>yy-3)&&(yuspex; + uspex_output_struct *uspex_output=model->uspex; /*we have a hit*/ graph->select=struct_sel; graph->select_2=ptr[i]; @@ -442,7 +442,7 @@ for (list=graph->set_list ; list ; list=g_slist_next(list)) graph->select_label=g_strdup_printf("[%i,%f]",struct_sel+1,ptr[i]); vf=fopen(model->filename, "r"); if(!vf) return; - if((*uspex_calc).method==US_CM_META) n_struct++; + if((*uspex_output).calc->calculationMethod==US_CM_META) n_struct++; model->cur_frame=n_struct+i-1; read_raw_frame(vf,n_struct+i-1,model); fclose(vf); From a643cae8831be9b3d8c6a3ff185300a0c5ca3bd1 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 10 Aug 2018 21:20:23 +0900 Subject: [PATCH 21/56] gui_uspex: FIX METADYNAMICS + uspex parameters VIII. --- src/file_uspex.c | 193 +++++++++++++++++++++++++++++++++++++---------- src/gl_graph.c | 4 +- 2 files changed, 154 insertions(+), 43 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 9b177ae..76639cd 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -276,7 +276,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); k=0;sscanf(line,"%i%*s",&(k)); j=k; i=((int)(j/100))%10; - if((i<0)||(i>3)) { + if((i!=-2)&&((i<0)||(i>3))) { g_free(line); line = file_read_line(vf); continue; @@ -1376,7 +1376,6 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ FILE *vf; long int vfpos; gchar *line=NULL; - gchar tmp[64]; uspex_output_struct *uspex_output=model->uspex; /* specific */ gint idx=0; @@ -1431,24 +1430,26 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ } _UO.num_struct--; fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + g_free(line); line = file_read_line(vf); /* now prepare arrays <- JOB=USPEX/300 example */ if(_UO.num_struct==0) return 1; _UO.red_index=g_malloc(max_struct*sizeof(gint)); for(idx=0;idxcalculationMethod==US_CM_META) red_index--;/*because of META "special" numbering*/ if(_UO.ind[idx].gen<_UO.num_gen) _UO.ind[idx].gen++; if(_UO.ind[idx].gen>_UO.num_gen) _UO.num_gen=_UO.ind[idx].gen; /*_VALGRIND_BUG_: _UO.red_index[red_index]=idx;*/ @@ -1456,7 +1457,7 @@ if(_UO.have_fitness){ if(!e_red) _UO.ind[idx].E=_UO.ind[idx].energy/_UO.ind[idx].natoms; else _UO.ind[idx].E=_UO.ind[idx].energy; #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX[Individual]: GEN=%i STRUCT=%i e=%lf n_atom=%i E=%lf\n",_UO.ind[idx].gen,idx+1,_UO.ind[idx].energy,_UO.ind[idx].natoms,_UO.ind[idx].E); +fprintf(stdout,"#DBG: USPEX[Individual]: GEN=%i STRUCT=%i e=%lf E=%lf\n",_UO.ind[idx].gen,idx+1,_UO.ind[idx].energy,_UO.ind[idx].E); #endif if(_UO.ind[idx].E<_UO.min_E) _UO.min_E=_UO.ind[idx].E; if(_UO.ind[idx].E>_UO.max_E) _UO.max_E=_UO.ind[idx].E; @@ -1673,7 +1674,8 @@ if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ model->basename=g_strdup_printf("uspex"); /* we have to open structure file first because of inconsistency in atom reporting in Individuals file*/ /* --- READ gatheredPOSCARS <- this is going to be the main model file */ -/* ^^^ META: If gatheredPOSCARS_relaxed exists, read it instead */ +/* ^^^ META is ill-defined: read first gatheredPOSCARS, then update with gatheredPOSCARS_relaxed in the future TODO*/ +/* if(_UC.calculationMethod==US_CM_META) { aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); vf = fopen(aux_file, "rt"); @@ -1685,6 +1687,8 @@ if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ }else{ aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); } +*/ + aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); vf = fopen(aux_file, "rt"); if (!vf) { if(_UO.ind!=NULL) g_free(_UO.ind); @@ -1782,18 +1786,8 @@ if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ g_free(aux_file); fclose(vf); /* --- READ Individuals <- information about all structures */ -/* ^^^ META: If Individuals_relaxed exists, read it instead */ - if(_UC.calculationMethod==US_CM_META) { - aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); - vf = fopen(aux_file, "rt"); - if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); - else { - fclose(vf); - vf=NULL; - } - }else{ - aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); - } +/* ^^^ META is ill-defined: read first Individuals, then update with Individual_relaxed and hope*/ + aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); if(read_individuals_uspex(aux_file,model)!=0) { line = g_strdup_printf("ERROR: reading USPEX Individuals file!\n"); gui_text_show(ERROR, line); @@ -1801,20 +1795,55 @@ if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ goto uspex_fail; } g_free(aux_file); -/* --- open the last frame */ if(_UC.calculationMethod==US_CM_META) { - aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); + aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); vf = fopen(aux_file, "rt"); if (!vf) { g_free(aux_file); - aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); - } else { + }else{ + /*we have an Individuals_relaxed, read it and update ONLY the structure defined inside*/ + vfpos=ftell(vf);/* flag */ + line = file_read_line(vf); + while(line){ + ptr=&(line[0]); + while(*ptr==' ') ptr++; + if(g_ascii_isdigit(*ptr)) { + fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + break; + } + vfpos=ftell(vf);/* flag */ + g_free(line); + line = file_read_line(vf); + } + g_free(line); + fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + line = file_read_line(vf); + if(line==NULL) goto no_ind_relax; + /*skip the gen=0 value!!*/ + g_free(line);line = file_read_line(vf); + vfpos=ftell(vf);/* flag */ + /*no need to count, there will be less structure*/ + line = file_read_line(vf); + while(line){ + sscanf(line," %*i %i %*s",&idx); + if(_UO.have_fitness){ +sscanf(line," %i %*i%*[^[][%*[^]]] %lf %lf %*f %lf %*s", + &(_UO.ind[idx].gen),&(_UO.ind[idx].energy),&(_UO.ind[idx].volume),&(_UO.ind[idx].fitness)); +if(isnan(_UO.ind[idx].fitness)) _UO.ind[idx].fitness=10000; + }else{ +sscanf(line," %i %*i%*[^[][%*[^]]] %lf %lf %*s", + &(_UO.ind[idx].gen),&(_UO.ind[idx].energy),&(_UO.ind[idx].volume)); +} + g_free(line); + line = file_read_line(vf); + } +no_ind_relax: fclose(vf); - vf=NULL; } - }else{ - aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); } +/* --- open the last frame */ +/* ^^^ META is ill-defined: read first gatheredPOSCARS, then update with gatheredPOSCARS_relaxed in the future TODO*/ + aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); vf = fopen(aux_file, "rt");g_free(aux_file); if (!vf) {/*very unlikely, we just opened it*/ if(_UO.ind!=NULL) g_free(_UO.ind); @@ -1825,22 +1854,89 @@ if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ } read_frame_uspex(vf,model);/*open first frame*/ fclose(vf);vf=NULL; - /* --- Prepare the summary graph */ - /*no need to load BESTIndividuals since we already know everything from Individuals*/ - _UO.graph=graph_new("ALL", model); - _UO.graph_best=graph_new("BEST", model); +/* ^^^ META is ill-defined: but we can read BESTIndividuals_relaxed instead of BESTIndividuals, hurrah!*/ if(_UO.num_struct>_UO.num_gen){ + _UO.graph=graph_new("ALL", model); + _UO.graph_best=graph_new("BEST", model); + _UO.num_best=_UO.num_gen;/*I hope this one is always true*/ + _UO.best_ind=g_malloc((1+_UO.num_best)*sizeof(gint)); + for(ix=0;ix<(1+_UO.num_best);ix++) _UO.best_ind[ix]=0; + /*NEW: read BESTIndividuals IDs first, when exists!*/ +if(_UO.calc->calculationMethod==US_CM_META){ + aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals_relaxed"); + vf = fopen(aux_file, "rt");g_free(aux_file); + if(!vf) { + aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals"); + vf = fopen(aux_file, "rt");g_free(aux_file); + } +}else{ + aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals"); + vf = fopen(aux_file, "rt");g_free(aux_file); +} + probe=0; +if(vf){ + /*read BESTIndividuals*/ + /*skip header, avoid _BUG_ when Individual format have 1 OR 2 line header.*/ + vfpos=ftell(vf);/* flag */ + line = file_read_line(vf); + while(line){ + ptr=&(line[0]); + while(*ptr==' ') ptr++; + if(g_ascii_isdigit(*ptr)) { + fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + break; + } + vfpos=ftell(vf);/* flag */ + g_free(line); + line = file_read_line(vf); + } + if(line==NULL) goto no_best_ind; + /* META calculation have a gen=0 Individual + unfortunately, it is *not* in the gather- + -POSCARS file, so we ignore gen=0 for now. */ + if(_UO.calc->calculationMethod==US_CM_META){ + g_free(line); + line = file_read_line(vf); + vfpos=ftell(vf);/* flag */ + } + /*count best stuctures*/ + num=0; + while (line){ + num++; + g_free(line); + line = file_read_line(vf); + } + num--; + if(num>_UO.num_best) goto no_best_ind;/*num<_UO.num_best is allowed for unfinished calculation*/ + fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + line = file_read_line(vf); + /*now fill array*/ + while(line){ + sscanf(line," %i %i %*s",&gen,&ix); + ix--; + if(_UO.calc->calculationMethod==US_CM_META) ix--;/*META "special" numbering*/ + _UO.best_ind[gen]=ix; +#if DEBUG_USPEX_READ + fprintf(stdout,"#DBG: USPEX GEN=%i BESTIndividuals=%i E=%f f=%f\n", + gen,ix+1,_UO.ind[_UO.best_ind[gen]].energy,_UO.ind[_UO.best_ind[gen]].fitness); +#endif + g_free(line); + line = file_read_line(vf); + } + /*that's all <- we get values directly from Individuals*/ + probe=1; +no_best_ind: + fclose(vf); +} skip=0; gen=1; - _UO.num_best=_UO.num_gen; - _UO.best_ind=g_malloc((1+_UO.num_best)*sizeof(gint)); - _UO.best_ind[0]=0; ix=0; while(gen<=_UO.num_gen){ while(_UO.ind[ix].gen=_UO.num_struct) break;/*FIX _VALGRIND_BUG_*/ } +}else{ + min_E=_UO.ind[_UO.best_ind[gen]].E; + if(_UO.have_fitness) min_F=_UO.ind[_UO.best_ind[gen]].fitness; + while(_UO.ind[ix].gen==gen){ + num++; + ix++; + if(ix>=_UO.num_struct) break; + } +} e=g_malloc((1+num)*sizeof(gdouble)); ix=skip; e[0]=(gdouble)num; @@ -1880,16 +1985,22 @@ if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ max_E=_UO.ind[_UO.best_ind[1]].E; min_E=max_E; for(gen=0;gen<_UO.num_gen;gen++) { - if(_UO.ind[_UO.best_ind[gen+1]].E>max_E) max_E=_UO.ind[_UO.best_ind[gen+1]].E; - if(_UO.ind[_UO.best_ind[gen+1]].Ee[gen+1]) min_E=e[gen+1]; #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX_BEST: GEN=%i STRUCT=%i E=%lf\n",gen+1,1+_UO.best_ind[gen+1],e[gen+1]); +fprintf(stdout,"#DBG: USPEX_BEST: GEN=%i STRUCT=%i E=%lf e=%f\n",gen+1,1+_UO.best_ind[gen+1],e[gen+1],_UO.ind[_UO.best_ind[gen+1]].energy); #endif } - if(_UC.calculationMethod==US_CM_META) {/*shift best_ind by 1*/ +/* + if(_UC.calculationMethod==US_CM_META) {//shift best_ind by 1 for(gen=1;gen<=_UO.num_gen;gen++) _UO.best_ind[gen]++; } +*/ + if(max_E==min_E) { + min_E-=0.1; + max_E+=0.1; + } graph_add_borned_data( _UO.num_gen,e,0,_UO.num_gen, min_E-(max_E-min_E)*0.05,max_E+(max_E-min_E)*0.05,GRAPH_USPEX_BEST,_UO.graph_best); diff --git a/src/gl_graph.c b/src/gl_graph.c index 49eec9b..70c3045 100644 --- a/src/gl_graph.c +++ b/src/gl_graph.c @@ -434,7 +434,7 @@ for (list=graph->set_list ; list ; list=g_slist_next(list)) yy *= -1; yy += oy; if((y>yy-3)&&(yuspex; +// uspex_output_struct *uspex_output=model->uspex; /*we have a hit*/ graph->select=struct_sel; graph->select_2=ptr[i]; @@ -442,7 +442,7 @@ for (list=graph->set_list ; list ; list=g_slist_next(list)) graph->select_label=g_strdup_printf("[%i,%f]",struct_sel+1,ptr[i]); vf=fopen(model->filename, "r"); if(!vf) return; - if((*uspex_output).calc->calculationMethod==US_CM_META) n_struct++; +// if((*uspex_output).calc->calculationMethod==US_CM_META) n_struct++; model->cur_frame=n_struct+i-1; read_raw_frame(vf,n_struct+i-1,model); fclose(vf); From 5bcda653d61ab1088f63f9d06b47e95a9a65af4a Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 13 Aug 2018 20:09:13 +0900 Subject: [PATCH 22/56] gui_uspex: gui_uspex 0. --- src/file_uspex.c | 181 +++++++++++++-- src/file_uspex.h | 18 +- src/gui_main.c | 1 + src/gui_uspex.c | 586 +++++++++++++++++++++++++++++++++++++++++++++++ src/gui_uspex.h | 85 +++++++ src/interface.h | 3 +- src/main.c | 1 + src/makefile.src | 2 +- src/pak.h | 1 + 9 files changed, 851 insertions(+), 27 deletions(-) create mode 100644 src/gui_uspex.c create mode 100644 src/gui_uspex.h diff --git a/src/file_uspex.c b/src/file_uspex.c index 76639cd..f423b50 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -175,6 +175,30 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.FormatType=2;/*MUST BE VASP FORMAT!*/ _UC.PrintStep=1; } +void free_uspex_parameters(uspex_calc_struct *uspex_calc){ + /*free the sub-structures, and set it back to init*/ + g_free(_UC.name); + g_free(_UC.atomType); + g_free(_UC.numSpecies); + g_free(_UC.valences); + g_free(_UC.goodBonds); + g_free(_UC.symmetries); + g_free(_UC.specificSwaps); + g_free(_UC.IonDistances); + g_free(_UC.MolCenters); + g_free(_UC.Latticevalues); + g_free(_UC.splitInto); + g_free(_UC.abinitioCode); + g_free(_UC.KresolStart); + g_free(_UC.vacuumSize); + g_free(_UC.commandExecutable); + g_free(_UC.remoteFolder); + g_free(_UC.valenceElectr); + g_free(_UC.softMutOnly); + g_free(_UC.specificTrans); + g_free(_UC.pickupImages); + init_uspex_parameters(uspex_calc); +} /************************************************************************/ /* Read Parameters.txt and fill keywords of uspex_calc_struct structure */ /************************************************************************/ @@ -964,6 +988,139 @@ fprintf(stdout,"#DBG: PROBE FAIL LINE: %s",line); #undef __GET_CHARS #undef __NSPECIES } +void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ +#define _SRC (*src) +#define _DEST (*dest) +#define _CP(value) _DEST.value=_SRC.value +#define _COPY(value,size,type) do{\ + if((_SRC.value)!=NULL){\ + memcpy(_DEST.value,_SRC.value,size*sizeof(type));\ + }else{\ + _DEST.value=NULL;\ + }\ +}while(0) +/*1st free / init the destination*/ +free_uspex_parameters(dest); +init_uspex_parameters(dest); +/*copy*/ +_CP(name); +_CP(special); +_CP(calculationMethod); +_CP(calculationType); +_CP(_calctype_dim); +_CP(_calctype_mol); +_CP(_calctype_var); +_CP(optType); +_CP(_nspecies); +_COPY(atomType,_SRC._nspecies,gint); +_CP(_var_nspecies); +_COPY(numSpecies,(_SRC._nspecies*_SRC._var_nspecies),gint); +_CP(ExternalPressure); +_COPY(valences,_SRC._nspecies,gint); +_COPY(goodBonds,(_SRC._nspecies*_SRC._nspecies),gdouble); +_CP(checkMolecules); +_CP(checkConnectivity); +_CP(populationSize); +_CP(initialPopSize); +_CP(numGenerations); +_CP(stopCrit); +_CP(bestFrac); +_CP(keepBestHM); +_CP(reoptOld); +_COPY(symmetries,strlen(_SRC.symmetries),gchar); +_CP(fracGene); +_CP(fracRand); +_CP(fracPerm); +_CP(fracAtomsMut); +_CP(fracRotMut); +_CP(fracLatMut); +_CP(howManySwaps); +_COPY(specificSwaps,strlen(_SRC.specificSwaps),gchar); +_CP(mutationDegree); +_CP(mutationRate); +_CP(DisplaceInLatmutation); +_CP(AutoFrac); +_CP(minVectorLength); +_COPY(IonDistances,(_SRC._nspecies*_SRC._nspecies),gdouble); +_CP(constraint_enhancement); +_COPY(MolCenters,_SRC._nmolecules,gdouble); +if(_SRC._calctype_var){ + _COPY(Latticevalues,_SRC._nlatticevalues,gdouble); +}else{ + if(_SRC._nlatticevalues==6) _COPY(Latticevalues,6,gdouble); + else if(_SRC._nlatticevalues<=3) _COPY(Latticevalues,_SRC._nlatticevalues*_SRC._nlatticevalues,gdouble); + else if(_SRC._nlatticevalues==1) _COPY(Latticevalues,1,gdouble); +} +_COPY(splitInto,_SRC._nsplits,gint); +_COPY(abinitioCode,_SRC._num_opt_steps,gint); +_COPY(KresolStart,_SRC._num_opt_steps,gdouble); +_COPY(vacuumSize,_SRC._num_opt_steps,gdouble); +_CP(numParallelCalcs); +_COPY(commandExecutable,strlen(_SRC.commandExecutable),gchar); +_CP(whichCluster); +_COPY(remoteFolder,strlen(_SRC.remoteFolder),gchar); +_CP(PhaseDiagram); +_CP(RmaxFing); +_CP(deltaFing); +_CP(sigmaFing); +_CP(antiSeedsActivation); +_CP(antiSeedsMax); +_CP(antiSeedsSigma); +_CP(doSpaceGroup); +_CP(SymTolerance); +_CP(repeatForStatistics); +_CP(stopFitness); +_CP(collectForces); +_CP(ordering_active); +_CP(symmetrize); +_COPY(valenceElectr,_SRC._nspecies,gint); +_CP(percSliceShift); +_CP(dynamicalBestHM); +_COPY(softMutOnly,strlen(_SRC.softMutOnly),gchar); +_CP(maxDistHeredity); +_CP(manyParents); +_CP(minSlice); +_CP(maxSlice); +_CP(numberparents); +_CP(thicknessS); +_CP(thicknessB); +_CP(reconstruct); +_CP(firstGeneMax); +_CP(minAt); +_CP(maxAt); +_CP(fracTrans); +_CP(howManyTrans); +_COPY(specificTrans,_SRC._nspetrans,gint); +_CP(GaussianWidth); +_CP(GaussianHeight); +_CP(FullRelax); +_CP(maxVectorLength); +_CP(PSO_softMut); +_CP(PSO_BestStruc); +_CP(PSO_BestEver); +_CP(vcnebType); +_CP(_vcnebtype_method); +_CP(_vcnebtype_img_num); +_CP(_vcnebtype_spring); +_CP(numImages); +_CP(numSteps); +_CP(optReadImages); +_CP(optimizerType); +_CP(optRelaxType); +_CP(dt); +_CP(ConvThreshold); +_CP(VarPathLength); +_CP(K_min); +_CP(K_max); +_CP(Kconstant); +_CP(optFreezing); +_CP(optMethodCIDI); +_CP(startCIDIStep); +_COPY(pickupImages,_SRC._npickimg,gint); +_CP(FormatType); +_CP(PrintStep); +} + /*****************************************/ /* OUTPUT a minimal uspex parameter file */ /*****************************************/ @@ -1651,12 +1808,6 @@ if(job>-1){ } g_free(aux_file); uspex_calc=_UO.calc; - -/* - if(dump_uspex_parameters("out.uspex",_UO.calc)){ - fprintf(stdout,"ERR: couldn't write Parameters.txt file: out.uspex\n"); - } -*/ /* --- CHECK type from Parameters.txt matches that of OUTPUT.TXT */ if((job!=-1)&&(job!=_UC.calculationType)){ /*since VCNEB will fail here due to a non-unified OUTPUT.txt format @@ -1675,19 +1826,6 @@ if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ /* we have to open structure file first because of inconsistency in atom reporting in Individuals file*/ /* --- READ gatheredPOSCARS <- this is going to be the main model file */ /* ^^^ META is ill-defined: read first gatheredPOSCARS, then update with gatheredPOSCARS_relaxed in the future TODO*/ -/* - if(_UC.calculationMethod==US_CM_META) { - aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); - vf = fopen(aux_file, "rt"); - if (!vf) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); - else { - fclose(vf); - vf=NULL; - } - }else{ - aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); - } -*/ aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); vf = fopen(aux_file, "rt"); if (!vf) { @@ -1992,11 +2130,6 @@ if(probe==0){ fprintf(stdout,"#DBG: USPEX_BEST: GEN=%i STRUCT=%i E=%lf e=%f\n",gen+1,1+_UO.best_ind[gen+1],e[gen+1],_UO.ind[_UO.best_ind[gen+1]].energy); #endif } -/* - if(_UC.calculationMethod==US_CM_META) {//shift best_ind by 1 - for(gen=1;gen<=_UO.num_gen;gen++) _UO.best_ind[gen]++; - } -*/ if(max_E==min_E) { min_E-=0.1; max_E+=0.1; diff --git a/src/file_uspex.h b/src/file_uspex.h index 17dd60c..f392af4 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -72,6 +72,7 @@ typedef struct { typedef struct { /*additional controls*/ gchar *name; /*the job name*/ + gchar *filename; /*corresponding filename*/ gint special; /*special tag*/ /*4.1 Type of run & System*/ uspex_method calculationMethod; /*supported calculation methods*/ @@ -214,12 +215,19 @@ typedef struct { gint PrintStep; /*save VC-NEB restart files in STEP directory every PS steps*/ /*6.3 Set initial pathway in VC-NEB*/ /*no keyword in this section*/ + + + +/*run parameters*/ + gchar *job_uspex_exe; + gchar *job_path; } uspex_calc_struct; /* global output structure */ typedef struct { /*name*/ gchar *name; gint version; + gint index; /*index is the # of result folder*/ uspex_calc_struct *calc; /* details */ gint dim; @@ -230,7 +238,7 @@ typedef struct { /*structures*/ gint num_gen; gint num_struct; - gint *red_index; /*in case not all structure are displayed (ie. META)*/ + gint *red_index; /*in case not all structure are displayed (ie. META)*/ gdouble min_E; gdouble max_E; uspex_individual *ind; @@ -244,6 +252,7 @@ typedef struct { /* execution structure */ typedef struct { int job_id; + gint index; /*index is the result# folder*/ gboolean have_result; /*job related*/ gchar *job_uspex_exe; @@ -251,4 +260,11 @@ typedef struct { } uspex_exec_struct; /*methods of interest*/ +void init_uspex_parameters(uspex_calc_struct *uspex_calc); +void free_uspex_parameters(uspex_calc_struct *uspex_calc); +uspex_calc_struct *read_uspex_parameters(gchar *filename); +void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest); +gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc); + + diff --git a/src/gui_main.c b/src/gui_main.c index 5ea9fbc..a9c8510 100644 --- a/src/gui_main.c +++ b/src/gui_main.c @@ -1376,6 +1376,7 @@ static GtkItemFactoryEntry menu_items[] = { "/Tools/Computation/Monty...", NULL, monty_dialog, 0, NULL }, { "/Tools/Computation/SIESTA...", NULL, gui_siesta_dialog, 0, NULL }, { "/Tools/Computation/VASP...", NULL, gui_vasp_dialog, 0, NULL }, + { "/Tools/Computation/USPEX...", NULL, gui_uspex_dialog, 0, NULL }, { "/Tools/Analysis", NULL, NULL, 0, "" }, { "/Tools/Analysis/Dynamics...", NULL, gui_analysis_dialog, 0, NULL }, diff --git a/src/gui_uspex.c b/src/gui_uspex.c new file mode 100644 index 0000000..442a7de --- /dev/null +++ b/src/gui_uspex.c @@ -0,0 +1,586 @@ +/* +Copyright (C) 2018 by Okadome Valencia + +hubert.valencia _at_ imass.nagoya-u.ac.jp + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +The GNU GPL can also be found at http://www.gnu.org +*/ + +/* simple USPEX launcher */ + +#include +#include +#include +#include +#include +#include +#include + + +#include "gdis.h" +#include "coords.h" +#include "model.h" +#include "file.h" +#include "matrix.h" +#include "module.h" +#include "numeric.h" +#include "parse.h" +#include "project.h" +#include "render.h" +#include "spatial.h" +#include "quaternion.h" +#include "task.h" +#include "interface.h" +#include "dialog.h" +#include "gui_shorts.h" +#include "file_uspex.h" +#include "gui_defs.h" +#include "gui_uspex.h" + +extern struct sysenv_pak sysenv; + +/*globals variables*/ +struct uspex_calc_gui uspex_gui; + +/*************************/ +/* initialize gui values */ +/*************************/ +void gui_uspex_init(){ + uspex_gui.cur_page=USPEX_PAGE_SET_I; + uspex_gui.is_dirty=TRUE; +} +/************************************************************/ +/* Load calculation setting from an included Parameters.txt */ +/************************************************************/ +void load_parameters_dialog(void){ + GUI_OBJ *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(uspex_gui.window,file_chooser,"Select a Parameters.txt File","*.txt","Parameters.txt files"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + uspex_calc_struct *test_calc; + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(uspex_gui.file_entry,text); + g_free(text); + test_calc = read_uspex_parameters(filename); + if(test_calc != NULL) { + /*unable to open Parameters.txt*/ + }else{ + copy_uspex_parameters(test_calc,&(uspex_gui.calc)); + uspex_gui_refresh();/*refresh GUI with new uspex_gui.calc*/ + } + g_free (filename); + free_uspex_parameters(test_calc); + g_free(test_calc); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); +} +/****************************/ +/* load the uspex executable */ +/****************************/ +void load_uspex_exe_dialog(void){ + GUI_OBJ *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(uspex_gui.window,file_chooser,"Select USPEX Executable","uspex","uspex_exec"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(uspex_gui.job_uspex_exe,text); + g_free(text); + USPEX_REG_TEXT(job_uspex_exe); + g_free (filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); +} +/*****************************************/ +/* point to the path to run the USPEX job */ +/*****************************************/ +void uspex_path_dialog(void){ + GUI_OBJ *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_FOLDER(uspex_gui.window,file_chooser,"Select working folder"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_ENTRY_TEXT(uspex_gui.job_path,text); + g_free(text); + USPEX_REG_TEXT(job_path); + g_free (filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); +} +/**************************************************/ +/* refresh the GUI with value from uspex_gui.calc */ +/**************************************************/ +void uspex_gui_refresh(){ +// gchar *text; + /*refresh the whole GUI based on uspex_gui.calc information*/ +} +/*******************************/ +/* selecting calculationMethod */ +/*******************************/ +void uspex_method_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 0://USPEX + uspex_gui.calc.calculationMethod = US_CM_USPEX;break; + case 1://META + uspex_gui.calc.calculationMethod = US_CM_META;break; + case 2://VCNEB + uspex_gui.calc.calculationMethod = US_CM_VCNEB;break; + case 3://PSO + uspex_gui.calc.calculationMethod = US_CM_PSO;break; + case 4://UNKNOWN + default: + uspex_gui.calc.calculationMethod = US_CM_UNKNOWN; + } +} +/******************************************************/ +/* Transfer gdouble spin value into proper gint: _dim */ +/******************************************************/ +void spin_update_dim(){ + uspex_gui.calc._calctype_dim=(gint)uspex_gui._dim; +} +/*****************************************/ +/* toggle mol -> update calculation type */ +/*****************************************/ +void mol_toggle(void){ + gchar *text; + if(uspex_gui.calc._calctype_mol){ + if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10+1; + else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10; + }else{ + if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+1; + else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100; + } + text=g_strdup_printf("%i",uspex_gui.calc.calculationType); + GUI_ENTRY_TEXT(uspex_gui.calculationType,text); + g_free(text); +} +/*****************************************/ +/* toggle var -> update calculation type */ +/*****************************************/ +void var_toggle(void){ + gchar *text; + if(uspex_gui.calc._calctype_var){ + if(uspex_gui.calc._calctype_mol) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10+1; + else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+1; + }else{ + if(uspex_gui.calc._calctype_mol) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10; + else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100; + } + text=g_strdup_printf("%i",uspex_gui.calc.calculationType); + GUI_ENTRY_TEXT(uspex_gui.calculationType,text); + g_free(text); +} +/***********************************/ +/* selecting optimization property */ +/***********************************/ +void uspex_optimization_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 0://1 + uspex_gui.calc.optType=US_OT_ENTHALPY;break; + case 1://2 + uspex_gui.calc.optType=US_OT_VOLUME;break; + case 2://3 + uspex_gui.calc.optType=US_OT_HARDNESS;break; + case 3://4 + uspex_gui.calc.optType=US_OT_ORDER;break; + case 4://5 + uspex_gui.calc.optType=US_OT_DISTANCE;break; + case 5://6 + uspex_gui.calc.optType=US_OT_DIELEC_S;break; + case 6://7 + uspex_gui.calc.optType=US_OT_GAP;break; + case 7://8 + uspex_gui.calc.optType=US_OT_DIELEC_GAP;break; + case 8://9 + uspex_gui.calc.optType=US_OT_MAG;break; + case 9://10 + uspex_gui.calc.optType=US_OT_QE;break; + case 10://1101 + uspex_gui.calc.optType=US_OT_BULK_M;break; + case 11://1102 + uspex_gui.calc.optType=US_OT_SHEAR_M;break; + case 12://1103 + uspex_gui.calc.optType=US_OT_YOUNG_M;break; + case 13://1104 + uspex_gui.calc.optType=US_OT_POISSON;break; + case 14://1105 + uspex_gui.calc.optType=US_OT_PUGH_R;break; + case 15://1106 + uspex_gui.calc.optType=US_OT_VICKERS_H;break; + case 16://1107 + uspex_gui.calc.optType=US_OT_FRACTURE;break; + case 17://1108 + uspex_gui.calc.optType=US_OT_DEBYE_T;break; + case 18://1109 + uspex_gui.calc.optType=US_OT_SOUND_V;break; + case 19://1110 + uspex_gui.calc.optType=US_OT_SWAVE_V;break; + case 20://1111 + uspex_gui.calc.optType=US_OT_PWAVE_V;break; + default: + uspex_gui.calc.optType=US_OT_UNKNOWN; + } +} + +/************************/ +/* Switch notebook page */ +/************************/ +void uspex_gui_page_switch(GUI_NOTE *notebook,GUI_OBJ *page,guint page_num){ + gint from_page; + gchar *text; + /* some (few) values need to be updated from a page to another*/ + GUI_NOTE_PAGE_NUMBER(notebook,from_page); + if(from_page==(gint)page_num) return;/*not moved*/ + uspex_gui.cur_page=page_num; + GUI_LOCK(page); + if(page_num==USPEX_PAGE_SET_I){ + /**/ + } else if(page_num==USPEX_PAGE_SET_II){ + /**/ + } else if (page_num==USPEX_PAGE_SPECIFICS){ + /**/ + } else if (page_num==USPEX_PAGE_ABINITIO){ + /**/ + } else if (page_num==USPEX_PAGE_EXEC){ + /**/ + } + GUI_UNLOCK(page); + /*to be continued...*/ +} +/****************************************************/ +/* convert current uspex_gui into uspex_calc_struct */ +/****************************************************/ +void uspex_gui_sync(){ + /* sync start here */ +} +/***************************/ +/* save current parameters */ +/***************************/ +gint save_uspex_calc(){ +#define DEBUG_USPEX_SAVE 0 + FILE *save_fp; + gchar *filename; + /*1-synchronize*/ + uspex_gui_sync(); + /*2-output*/ + //SAVE calculation parameters to INPUT.txt + filename=g_strdup_printf("%s/INPUT.txt",uspex_gui.calc.job_path); + if(dump_uspex_parameters(filename,&(uspex_gui.calc))<0){ + fprintf(stderr,"#ERR: can't open file INPUT.txt for WRITE!\n"); + return -1; + } + g_free(filename); + /*debug print*/ +#if DEBUG_USPEX_SAVE + dump_uspex_parameters(stdout,&(uspex_gui.calc)); +#endif + return 0; +} +/*********************************/ +/* Cleanup calculation structure */ +/*********************************/ +void uspex_cleanup(){ + /*we don't have to free anything.. everything will be hopefully gone after the dialog is closed*/ +} +/*****************************************/ +/* Execute or enqueue a uspex calculation */ +/*****************************************/ +void run_uspex_exec(uspex_exec_struct *uspex_exec){ + /* Execute a uspex task TODO distant job */ + gchar *cmd; + gchar *cwd;/*for push/pull*/ + +#if __WIN32 +/* At present running uspex in __WIN32 environment is impossible. + * However, it should be possible to launch a (remote) job on a + * distant server. See TODO */ + fprintf(stderr,"USPEX calculation can't be done in this environment.\n");return; +#else + /*direct launch*/ + cmd = g_strdup_printf("%s > uspex.log",(*uspex_exec).job_uspex_exe); +#endif + cwd=sysenv.cwd;/*push*/ + sysenv.cwd=g_strdup_printf("%s",(*uspex_exec).job_path); + task_sync(cmd); + g_free(sysenv.cwd); + sysenv.cwd=cwd;/*pull*/ + g_free(cmd); + (*uspex_exec).have_result=TRUE; +} +/*****************************/ +/* cleanup task: load result */ +/*****************************/ +void cleanup_uspex_exec(uspex_exec_struct *uspex_exec){ + /*USPEX process has exit, try to load the result*/ + struct model_pak *result_model; + gchar *filename; + int index; + FILE *vf; + /*sync_ wait for result?*/ + while(!(*uspex_exec).have_result) usleep(500*1000);/*sleep 500ms until job is done*/ + /*init a model*/ + result_model=model_new(); + model_init(result_model); + /*put result into it*/ + /*1- find the last result folder*/ + index=1; + filename=g_strdup_printf("%s/results1/OUTPUT.txt",(*uspex_exec).job_path); + vf=fopen(filename,"r"); + while(vf!=NULL){ + g_free(filename); + fclose(vf); + index++; + filename=g_strdup_printf("%s/results%i/OUTPUT.txt",(*uspex_exec).job_path,index); + vf=fopen(filename,"r"); + } + index--; + g_free(filename); + /*this is the last openable folder/OUTPUT.txt*/ + filename=g_strdup_printf("%s/results%i/OUTPUT.txt",(*uspex_exec).job_path,index); + (*uspex_exec).index=index; + /*TODO: detect if a calculation have failed*/ + file_load(filename,result_model);/*TODO: load result without annoying tree_select_active*/ + model_prep(result_model); + tree_model_add(result_model); + tree_model_refresh(result_model); + canvas_shuffle(); + redraw_canvas(ALL);/*ALL: necessary?*/ +/*just wipe the structure*/ + sysenv.uspex_calc_list=g_slist_remove(sysenv.uspex_calc_list,uspex_exec);/*does not free, does it?*/ + g_free(uspex_exec); +} +/******************************/ +/* Enqueue a uspex calculation */ +/******************************/ +void uspex_exec_calc(){ + uspex_exec_struct *uspex_exec; + /*this will sync then enqueue a USPEX calculation*/ + if(save_uspex_calc()) return;/*sync and save all file*/ +/*copy structure to the list*/ + uspex_exec=g_malloc(sizeof(uspex_exec_struct)); + uspex_exec->job_id=g_slist_length(sysenv.uspex_calc_list); + uspex_exec->have_result=FALSE; + uspex_exec->job_uspex_exe=g_strdup_printf("%s",uspex_gui.calc.job_uspex_exe); + uspex_exec->job_path=g_strdup_printf("%s",uspex_gui.calc.job_path); + /*prepend to calc list*/ + sysenv.uspex_calc_list = g_slist_prepend (sysenv.uspex_calc_list,uspex_exec); + /*launch uspex in a task*/ + GUI_LOCK(uspex_gui.button_save); + GUI_LOCK(uspex_gui.button_exec); + task_new("USPEX", &run_uspex_exec,uspex_exec,&cleanup_uspex_exec,uspex_exec,sysenv.active_model); + /*when task is launched, close dialog*/ + uspex_cleanup(); + GUI_CLOSE(uspex_gui.window); +} +/********************************/ +/* Quit uspex calculation dialog */ +/********************************/ +void quit_uspex_gui(GUI_OBJ *w, gpointer data){ + struct model_pak *model=data; + uspex_cleanup(); + dialog_destroy(w,model); +} +/********************************/ +/* USPEX calculation main dialog */ +/********************************/ +void gui_uspex_dialog(void){ +/*launch the main interface*/ +/*TODO: use distant connections*/ + gchar *title; + gpointer dialog; + GUI_OBJ *frame, *vbox, *hbox, *table; + GUI_OBJ *notebook, *page, *button, *label; + GUI_OBJ *separator; + /* special */ + struct model_pak *data; + struct core_pak *core; + gint idx; + gchar *tmp; +/* checks */ + data = sysenv.active_model; + if (!data) return; +/* do we have a uspexrun.xml model? */ + if (data->id == USPEX) { + uspex_output_struct *uspex_output=data->uspex; + uspex_calc_struct *uspex_calc; + /*take GUI default from the opened USPEX output*/ + free_uspex_parameters(&(uspex_gui.calc)); + uspex_calc = read_uspex_parameters(_UO.calc->filename); + if(uspex_calc){ + uspex_gui.have_output=TRUE; + copy_uspex_parameters(uspex_calc,&(uspex_gui.calc)); + gui_uspex_init(); + }else{ + uspex_gui.have_output=FALSE; + init_uspex_parameters(&(uspex_gui.calc)); + gui_uspex_init(); + } + g_free(uspex_calc); + } else { + uspex_gui.have_output=FALSE; + init_uspex_parameters(&(uspex_gui.calc)); + gui_uspex_init(); + } +/* dialog setup */ + title = g_strdup_printf("USPEX: %s", data->basename); + dialog = dialog_request(CUSPEX, title, NULL, uspex_cleanup,data); + g_free(title); + uspex_gui.window = dialog_window(dialog); +/* --- Outside of notebook */ + GUI_FRAME_WINDOW(uspex_gui.window,frame); + GUI_VBOX_FRAME(frame,vbox); +/* --- MODEL NAME */ + GUI_LINE_BOX(vbox,hbox); + GUI_LABEL_BOX(hbox,label,"MODEL NAME"); + GUI_TEXT_ENTRY(hbox,uspex_gui.name,data->basename,TRUE); +GUI_TOOLTIP(uspex_gui.name,"The model name will be used in USPEX files\nas well as GDIS display."); +/* --- CONNECTED OUTPUT */ + GUI_LINE_BOX(vbox,hbox); + GUI_LABEL_BOX(hbox,label,"CONNECTED OUTPUT"); +if(uspex_gui.have_output){ + uspex_output_struct *uspex_output=data->uspex; + tmp=g_strdup_printf("%s",_UO.calc->filename); + GUI_TEXT_ENTRY(hbox,uspex_gui.file_entry,tmp,TRUE); + g_free(tmp); +}else{ + GUI_TEXT_ENTRY(hbox,uspex_gui.file_entry,"",TRUE); + +} +GUI_TOOLTIP(uspex_gui.file_entry,"Use the previous result of a USPEX calculation\nto fill the parameters of the current one.\nNOTE: all settings should be checked again. Carefully."); + GUI_OPEN_BUTTON_BOX(hbox,button,load_parameters_dialog); +/* create frame in box */ + GUI_FRAME_WINDOW(uspex_gui.window,frame); +/* create notebook in frame */ + GUI_NOTE_FRAME(frame,notebook); + +/*-----------------*/ +/* page 1 -> SET-I */ +/*-----------------*/ + GUI_PAGE_NOTE(notebook,page,"SET-I"); +/* --- Type & System */ + GUI_FRAME_NOTE(page,frame,"Type & System"); +/* create a table in the frame*/ + GUI_TABLE_FRAME(frame,table,5,3); +/* 1st line */ + GUI_COMBOBOX_TABLE(table,uspex_gui.calculationMethod,"calculationMethod: ",0,1,0,1); + GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"USPEX"); + GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"META"); + GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"VCNEB"); + GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"PSO"); +GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: USPEX\nSet the method of calculation."); + GUI_ENTRY_TABLE(table,uspex_gui.calculationType,uspex_gui.calc.calculationType,"%3i","calculationType:",1,2,0,1); +GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: 300\nSets the dimensionality, molecularity, and variability\nof the calculation, can also be set individually."); + GUI_SPIN_TABLE(table,uspex_gui._calctype_dim,uspex_gui._dim,spin_update_dim,"DIM",2,3,0,1); +GUI_TOOLTIP(uspex_gui._calctype_dim,"Set the dimension of the system.\n3, 2, 1, and 0 are equilvalent to 3D, 2D, 1D, and 0D.\n-2 correspond to 2D crystals."); + GUI_CHECK_TABLE(table,button,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",3,4,0,1); + + GUI_CHECK_TABLE(table,button,uspex_gui.calc._calctype_var,var_toggle,"VAR",4,5,0,1); +/* 2nd line */ + GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,1,1,2); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1: MIN Enthalpy"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"2: MIN Volume"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"3: MAX Hardness"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"4: MAX Degree of order"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"5: MAX Structure difference"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"6: MAX Dielect. suscept."); + GUI_COMBOBOX_ADD(uspex_gui.optType,"7: MAX Band gap"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"8: MAX Dielectric gap"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"9: MAX Magnetization"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"10: MAX Structure quasientropy"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1101: MAX Bulk modulus"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1102: MAX Shear modulus"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1103: MAX Young modulus"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1104: MAX Poisson Modulus"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1105: MAX Pugh ratio"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1106: MAX Vickers hardness"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1107: MAX Fracture toughness"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1108: MAX Debye temperature"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1109: MAX Sound velocity"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1110: MAX S-wave velocity"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1111: MAX P-wave velocity"); +GUI_TOOLTIP(uspex_gui.optType,"optType: Ch. 4.1 DEFAULT: 1(Enthalpy)\nSelect the properties to optimize."); + +/* initialize */ + GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); + GUI_COMBOBOX_SETUP(uspex_gui.optType,0,uspex_optimization_selected); + mol_toggle(); + var_toggle(); +/* --- end frame */ + +/*------------------*/ +/* page 2 -> SET-II */ +/*------------------*/ + GUI_PAGE_NOTE(notebook,page,"SET-II"); +/* --- end frame */ + +/*---------------------*/ +/* page 3 -> SPECIFICS */ +/*---------------------*/ + GUI_PAGE_NOTE(notebook,page,"SPECIFICS"); +/* --- end frame */ + +/*--------------------*/ +/* page 4 -> ABINITIO */ +/*--------------------*/ + GUI_PAGE_NOTE(notebook,page,"AB INITIO"); +/* --- end frame */ + +/*----------------*/ +/* page 5 -> EXEC */ +/*----------------*/ + GUI_PAGE_NOTE(notebook,page,"EXEC"); +/* --- end frame */ + +/* --- Outside of notebook */ + GUI_FRAME_WINDOW(uspex_gui.window,frame); + GUI_VBOX_FRAME(frame,vbox); +/* Action buttons */ + GUI_SAVE_ACTION(uspex_gui.window,uspex_gui.button_save,save_uspex_calc,NULL); + GUI_EXEC_ACTION(uspex_gui.window,uspex_gui.button_exec,uspex_exec_calc,NULL); + GUI_CLOSE_ACTION(uspex_gui.window,button,quit_uspex_gui,dialog); +/* connect to signals */ + GUI_PAGE_CHANGE(notebook,uspex_gui_page_switch,NULL); +/* all done */ + uspex_gui_refresh();/*refresh once more*/ + GUI_SHOW(uspex_gui.window);/*display*/ + sysenv.refresh_dialog=TRUE; +} + diff --git a/src/gui_uspex.h b/src/gui_uspex.h new file mode 100644 index 0000000..f3358e7 --- /dev/null +++ b/src/gui_uspex.h @@ -0,0 +1,85 @@ +/* +Copyright (C) 2018 by Okadome Valencia + +hubert.valencia _at_ imass.nagoya-u.ac.jp + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +The GNU GPL can also be found at http://www.gnu.org +*/ + +/* simple USPEX calcul interface */ +/* DEFINES: sync uspex_gui and uspex_gui.calc */ +#define USPEX_REG_VAL(value,format) do{\ + GUI_REG_VAL(uspex_gui.value,uspex_gui.calc.value,format);\ +}while(0) +#define USPEX_REG_TEXT(value) do{\ + if(uspex_gui.calc.value!=NULL) g_free(uspex_gui.calc.value);\ + if(GUI_ENTRY_LENGHT(uspex_gui.value)>0) GUI_ENTRY_GET_TEXT(uspex_gui.value,uspex_gui.calc.value);\ + else uspex_gui.calc.value=NULL;\ +}while(0) +/*page numbers*/ +#define USPEX_PAGE_SET_I 1 +#define USPEX_PAGE_SET_II 2 +#define USPEX_PAGE_SPECIFICS 3 +#define USPEX_PAGE_ABINITIO 4 +#define USPEX_PAGE_EXEC 5 +/* gui structure */ +struct uspex_calc_gui{ + /*window information*/ + GUI_OBJ *window; + /*connection to calculation parameters*/ + uspex_calc_struct calc; + /*actual GUI*/ + gint cur_page; + gboolean is_dirty; + GUI_OBJ *name; + GUI_OBJ *file_entry; + gboolean have_output; +/*4.1 Type of run & System*/ + GUI_OBJ *calculationMethod; + GUI_OBJ *calculationType; + GUI_OBJ *_calctype_dim; + gdouble _dim;/*absurd spin on double*/ + //_calctype_mol is auto-sync + //_calctype_var is auto-sync + GUI_OBJ *optType; + /*atoms definition: add/apply/remove*/ + GUI_OBJ *_atom_type; + GUI_OBJ *_atom_num; + GUI_OBJ *_atom_valence; + /*bond definition: apply/auto*/ + GUI_OBJ *goodBonds; + gboolean auto_bonds; + GUI_OBJ *Bonds; + /**/ + //checkMolecules is auto-sync + //checkConnectivity is auto-sync +/*4.2 Population*/ + + +/* CALCUL */ + GUI_OBJ *job_uspex_exe; + GUI_OBJ *job_path; + gboolean have_result; + gint index; +/*buttons*/ + GUI_OBJ *button_save; + GUI_OBJ *button_exec; +}; + +/*methods of interest*/ + +void uspex_gui_refresh(); diff --git a/src/interface.h b/src/interface.h index 280aa0e..f978c4c 100644 --- a/src/interface.h +++ b/src/interface.h @@ -66,7 +66,7 @@ NODATA, DATA, BIOSYM, CIF, FDF, GULP, MONTY, MARVIN, MORPH, META_DATA, XML, XTL, XYZ, MOL2, AUTO, CSSR, GAMOUT, PDB, GEOMVIEW_OFF, PROJECT, DOCKING, MDI, CREATOR, MVNOUT, GULPOUT, GULP_TRJ, SIESTA_OUT, VASP, CVASP, -USPEX, REPLACE_ATOMS, DYNAMICS, ZMATRIX, +USPEX, CUSPEX, REPLACE_ATOMS, DYNAMICS, ZMATRIX, OPENGL, OPENGL_OPTIONS, GAMESS, GAMESS_OUT, DIFFAX, DIFFAX_INP, DMOL_INPUT, ABINIT, ABINIT_OUT, NWCHEM, NWCHEM_OUT, CASTEP, CASTEP_OUT, GAUSS, GAUSS_OUT, QE, QE_OUT, @@ -149,6 +149,7 @@ void gui_defect_dialog(void); void gui_setup_dialog(void); void gui_siesta_dialog(void); void gui_vasp_dialog(void); +void gui_uspex_dialog(void); void gui_surface_widget(GtkWidget *); void gui_surface_setup(GtkWidget *); diff --git a/src/main.c b/src/main.c index 8e4ca47..97301b2 100644 --- a/src/main.c +++ b/src/main.c @@ -385,6 +385,7 @@ FILE *fp; /* top level structure initialization */ sysenv.vasp_calc_list = NULL;/*to be removed soon*/ +sysenv.uspex_calc_list = NULL; sysenv.max_threads = 1; sysenv.task_list = NULL; sysenv.host_list = NULL; diff --git a/src/makefile.src b/src/makefile.src index 24a83d9..434d56d 100644 --- a/src/makefile.src +++ b/src/makefile.src @@ -18,7 +18,7 @@ SRC = main.c model.c coords.c connect.c matrix.c module.c task.c \ ifeq ($(USE_GUI), YES) SRC := $(SRC) gui_main.c gui_canvas.c gui_shorts.c \ gl_main.c gl_primitives.c gl_stereo.c gl_graph.c gl_varray.c \ - gui_gulp.c gui_siesta.c gui_vasp.c gui_render.c gui_mdi.c gui_animate.c \ + gui_gulp.c gui_siesta.c gui_vasp.c gui_uspex.c gui_render.c gui_mdi.c gui_animate.c \ gui_edit.c gui_surface.c gui_analysis.c gui_defect.c \ gui_molsurf.c gui_diffract.c gui_gms.c gui_library.c gui_setup.c \ gui_gperiodic.c gui_plots.c gui_space.c gui_measure.c gui_symmetry.c gui_zmatrix.c \ diff --git a/src/pak.h b/src/pak.h index 9fb3c3d..ce22fc0 100644 --- a/src/pak.h +++ b/src/pak.h @@ -278,6 +278,7 @@ GThreadPool *thread_pool; /* temporary vasp calculation tasks. Will remove when remote job execution is ready --OVHPA*/ GSList *vasp_calc_list; +GSList *uspex_calc_list; /* CURRENT - task successor (remote job execution) */ GSList *host_list; From 1b5f52363bd987d6de489dde117cab63fc9abab5 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Tue, 14 Aug 2018 20:44:47 +0900 Subject: [PATCH 23/56] gui_uspex: gui_uspex I. --- src/file_uspex.h | 23 +++- src/gui_uspex.c | 298 ++++++++++++++++++++++++++++++++++++++++------- src/gui_uspex.h | 18 ++- 3 files changed, 286 insertions(+), 53 deletions(-) diff --git a/src/file_uspex.h b/src/file_uspex.h index f392af4..05da289 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -28,12 +28,23 @@ The GNU GPL can also be found at http://www.gnu.org /*structures*/ typedef enum {/*released USPEX calculation methods as of 2018 (5)*/ - US_CM_USPEX, /*USPEX*/ - US_CM_META, /*metadynamics*/ - US_CM_VCNEB, /*VC-NEB*/ - US_CM_PSO, /*PSO, unsupported*/ - US_CM_UNKNOWN, /*reserved for future use*/ + US_CM_USPEX, /*USPEX*/ + US_CM_META, /*metadynamics*/ + US_CM_VCNEB, /*VC-NEB*/ + US_CM_PSO, /*PSO, unsupported*/ + US_CM_UNKNOWN, /*reserved for future use*/ } uspex_method; +typedef enum{ + US_CT_300=300, /*bulk crystals; no-mol; no-var*/ + US_CT_301=301, /*bulk crystals; no-mol; var*/ + US_CT_310=310, /*bulk crystals; mol; no-var*/ + US_CT_311=311, /*bulk crystals; mol; var*/ + US_CT_000=0, /*nanoparticles; no-mol; no-var*/ + US_CT_110=110, /*polymers; no-mol; no-var*/ + US_CT_200=200, /*surfaces; no-mol; no-var*/ + US_CT_201=201, /*surfaces; no-mol; var*/ + US_CT_M200=-200, /*2D crystals; no-mol; no-var*/ +} uspex_type; typedef enum { US_OT_ENTHALPY=1, /*most stable structure*/ US_OT_VOLUME=2, /*min volume*/ @@ -76,7 +87,7 @@ typedef struct { gint special; /*special tag*/ /*4.1 Type of run & System*/ uspex_method calculationMethod; /*supported calculation methods*/ - gint calculationType; /*supported calculation types*/ + uspex_type calculationType; /*supported calculation types*/ gint _calctype_dim; /*HIDDEN: X.. digit in calculation type: dimension*/ gboolean _calctype_mol; /*HIDDEN: .X. digit in calculation type: molecular*/ gboolean _calctype_var; /*HIDDEN: ..X digit in calculation type: variable composition*/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 442a7de..dfa67bf 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -61,6 +61,7 @@ struct uspex_calc_gui uspex_gui; /*************************/ void gui_uspex_init(){ uspex_gui.cur_page=USPEX_PAGE_SET_I; + uspex_gui.auto_bonds=(uspex_gui.calc.goodBonds==NULL); uspex_gui.is_dirty=TRUE; } /************************************************************/ @@ -168,17 +169,156 @@ void uspex_method_selected(GUI_OBJ *w){ uspex_gui.calc.calculationMethod = US_CM_UNKNOWN; } } -/******************************************************/ -/* Transfer gdouble spin value into proper gint: _dim */ -/******************************************************/ +/*****************************/ +/* selecting calculationType */ +/*****************************/ +void uspex_type_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1://301 + uspex_gui.calc.calculationType=US_CT_301; + uspex_gui.calc._calctype_dim=3; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=TRUE; + break; + case 2://310 + uspex_gui.calc.calculationType=US_CT_310; + uspex_gui.calc._calctype_dim=3; + uspex_gui.calc._calctype_mol=TRUE; + uspex_gui.calc._calctype_var=FALSE; + break; + case 3://311 + uspex_gui.calc.calculationType=US_CT_311; + uspex_gui.calc._calctype_dim=3; + uspex_gui.calc._calctype_mol=TRUE; + uspex_gui.calc._calctype_var=TRUE; + break; + case 4://000 + uspex_gui.calc.calculationType=US_CT_000; + uspex_gui.calc._calctype_dim=0; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + break; + case 5://110 + uspex_gui.calc.calculationType=US_CT_110; + uspex_gui.calc._calctype_dim=1; + uspex_gui.calc._calctype_mol=TRUE; + uspex_gui.calc._calctype_var=FALSE; + break; + case 6://200 + uspex_gui.calc.calculationType=US_CT_200; + uspex_gui.calc._calctype_dim=2; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + break; + case 7://201 + uspex_gui.calc.calculationType=US_CT_201; + uspex_gui.calc._calctype_dim=2; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=TRUE; + break; + case 8://-200 + uspex_gui.calc.calculationType=US_CT_M200; + uspex_gui.calc._calctype_dim=-2; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + break; + case 0: + default://bad value -> default 300 + uspex_gui.calc.calculationType=US_CT_300; + uspex_gui.calc._calctype_dim=3; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + } + /*now update uspex_gui._calctype_dim, uspex_gui._calctype_mol, and uspex_gui._calctype_var*/ + GUI_SPIN_SET(uspex_gui._calctype_dim,(gdouble)uspex_gui.calc._calctype_dim); + if(uspex_gui.calc._calctype_mol) GUI_TOGGLE_ON(uspex_gui._calctype_mol); + else GUI_TOGGLE_OFF(uspex_gui._calctype_mol); + if(uspex_gui.calc._calctype_var) GUI_TOGGLE_ON(uspex_gui._calctype_var); + else GUI_TOGGLE_OFF(uspex_gui._calctype_var); +} +/**************************/ +/* update calculationType */ +/**************************/ +void _update_calculationType(){ + gint i=0; + switch(uspex_gui.calc._calctype_dim){ + case 3://300,301,310,311 + i=300; + if(uspex_gui.calc._calctype_mol) i+=10; + if(uspex_gui.calc._calctype_var) i+=1; + break; + case 2://200,201 + i=200; + if(uspex_gui.calc._calctype_mol) uspex_gui.calc._calctype_mol=FALSE; + if(uspex_gui.calc._calctype_var) i+=1; + break; + case 1://110 + i=110; + if(!uspex_gui.calc._calctype_mol) uspex_gui.calc._calctype_mol=TRUE; + if(uspex_gui.calc._calctype_var) uspex_gui.calc._calctype_var=FALSE; + break; + case 0://000 + i=0; + if(uspex_gui.calc._calctype_mol) uspex_gui.calc._calctype_mol=FALSE; + if(uspex_gui.calc._calctype_var) uspex_gui.calc._calctype_var=FALSE; + break; + case -2://-200 + i=-200; + if(uspex_gui.calc._calctype_mol) uspex_gui.calc._calctype_mol=FALSE; + if(uspex_gui.calc._calctype_var) uspex_gui.calc._calctype_var=FALSE; + break; + default://should not happen + i=300; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + } + uspex_gui.calc.calculationType=i; + switch(uspex_gui.calc.calculationType){ + case US_CT_301: + GUI_COMBOBOX_SET(uspex_gui.calculationType,1);break; + case US_CT_310: + GUI_COMBOBOX_SET(uspex_gui.calculationType,2);break; + case US_CT_311: + GUI_COMBOBOX_SET(uspex_gui.calculationType,3);break; + case US_CT_000: + GUI_COMBOBOX_SET(uspex_gui.calculationType,4);break; + case US_CT_110: + GUI_COMBOBOX_SET(uspex_gui.calculationType,5);break; + case US_CT_200: + GUI_COMBOBOX_SET(uspex_gui.calculationType,6);break; + case US_CT_201: + GUI_COMBOBOX_SET(uspex_gui.calculationType,7);break; + case US_CT_M200: + GUI_COMBOBOX_SET(uspex_gui.calculationType,8);break; + case US_CT_300: + default: + GUI_COMBOBOX_SET(uspex_gui.calculationType,0); + } +} +/************************/ +/* update _calctype_dim */ +/************************/ void spin_update_dim(){ - uspex_gui.calc._calctype_dim=(gint)uspex_gui._dim; + gint i=(gint)uspex_gui._dim; + /*ban the -1 value*/ + if(i==-1){ + if(uspex_gui.calc._calctype_dim==0) i=-2; + else i=0; + } + /*update calc value*/ + uspex_gui.calc._calctype_dim=i; + /*update spin value*/ + uspex_gui._dim=(gdouble)i; + GUI_SPIN_SET(uspex_gui._calctype_dim,uspex_gui._dim); + /*done, now update calculationType*/ + _update_calculationType(); } /*****************************************/ /* toggle mol -> update calculation type */ /*****************************************/ void mol_toggle(void){ - gchar *text; if(uspex_gui.calc._calctype_mol){ if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10+1; else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10; @@ -186,15 +326,13 @@ void mol_toggle(void){ if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+1; else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100; } - text=g_strdup_printf("%i",uspex_gui.calc.calculationType); - GUI_ENTRY_TEXT(uspex_gui.calculationType,text); - g_free(text); + /*done, now update calculationType*/ + _update_calculationType(); } /*****************************************/ /* toggle var -> update calculation type */ /*****************************************/ void var_toggle(void){ - gchar *text; if(uspex_gui.calc._calctype_var){ if(uspex_gui.calc._calctype_mol) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10+1; else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+1; @@ -202,9 +340,8 @@ void var_toggle(void){ if(uspex_gui.calc._calctype_mol) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10; else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100; } - text=g_strdup_printf("%i",uspex_gui.calc.calculationType); - GUI_ENTRY_TEXT(uspex_gui.calculationType,text); - g_free(text); + /*done, now update calculationType*/ + _update_calculationType(); } /***********************************/ /* selecting optimization property */ @@ -259,6 +396,44 @@ void uspex_optimization_selected(GUI_OBJ *w){ uspex_gui.calc.optType=US_OT_UNKNOWN; } } +/*****************************************************************/ +/* Change/ADD atomType, numSpecies, and valence of selected atom */ +/*****************************************************************/ +void apply_atom(){ +/*TODO*/ +} +/****************************************/ +/* Remove selected atomType information */ +/****************************************/ +void remove_atom(){ +/*TODO*/ +} +/*********************/ +/* toggle auto_bonds */ +/*********************/ +void auto_bond_toggle(void){ + if(uspex_gui.auto_bonds){ + GUI_LOCK(uspex_gui.goodBonds); + GUI_LOCK(uspex_gui._bond_d); + }else{ + GUI_UNLOCK(uspex_gui.goodBonds); + GUI_UNLOCK(uspex_gui._bond_d); + } +} +/************************************/ +/* Change/ADD goodBonds information */ +/************************************/ +void apply_bonds(){ +/*TODO*/ +} +/********************************/ +/* Remove goodBonds information */ +/********************************/ +void remove_bonds(){ +/*TODO*/ +} + + /************************/ /* Switch notebook page */ @@ -498,51 +673,92 @@ GUI_TOOLTIP(uspex_gui.file_entry,"Use the previous result of a USPEX calculation /* --- Type & System */ GUI_FRAME_NOTE(page,frame,"Type & System"); /* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,5,3); + GUI_TABLE_FRAME(frame,table,5,4); /* 1st line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.calculationMethod,"calculationMethod: ",0,1,0,1); + GUI_COMBOBOX_TABLE(table,uspex_gui.calculationMethod,"calcMethod: ",0,1,0,1); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"USPEX"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"META"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"VCNEB"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"PSO"); GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: USPEX\nSet the method of calculation."); - GUI_ENTRY_TABLE(table,uspex_gui.calculationType,uspex_gui.calc.calculationType,"%3i","calculationType:",1,2,0,1); -GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: 300\nSets the dimensionality, molecularity, and variability\nof the calculation, can also be set individually."); +GUI_COMBOBOX_TABLE(table,uspex_gui.calculationType,"calcType: ",1,2,0,1); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"300"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"301"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"310"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"311"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"000"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"110"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"200"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"201"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"-200"); +GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationType: Ch. 4.1 DEFAULT: 300\nSets the dimensionality, molecularity, and variability\nof the calculation, can also be set individually.\n(311) and (110) calculations may not be supported."); GUI_SPIN_TABLE(table,uspex_gui._calctype_dim,uspex_gui._dim,spin_update_dim,"DIM",2,3,0,1); + GUI_SPIN_RANGE(uspex_gui._calctype_dim,-2.,3.); GUI_TOOLTIP(uspex_gui._calctype_dim,"Set the dimension of the system.\n3, 2, 1, and 0 are equilvalent to 3D, 2D, 1D, and 0D.\n-2 correspond to 2D crystals."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",3,4,0,1); - - GUI_CHECK_TABLE(table,button,uspex_gui.calc._calctype_var,var_toggle,"VAR",4,5,0,1); + GUI_CHECK_TABLE(table,uspex_gui._calctype_mol,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",3,4,0,1); +GUI_TOOLTIP(uspex_gui._calctype_mol,"Set the molecularity of the system."); + GUI_CHECK_TABLE(table,uspex_gui._calctype_var,uspex_gui.calc._calctype_var,var_toggle,"VAR",4,5,0,1); +GUI_TOOLTIP(uspex_gui._calctype_var,"Set the variability of chemical composition."); /* 2nd line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,1,1,2); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1: MIN Enthalpy"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"2: MIN Volume"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"3: MAX Hardness"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"4: MAX Degree of order"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"5: MAX Structure difference"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"6: MAX Dielect. suscept."); - GUI_COMBOBOX_ADD(uspex_gui.optType,"7: MAX Band gap"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"8: MAX Dielectric gap"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"9: MAX Magnetization"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"10: MAX Structure quasientropy"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1101: MAX Bulk modulus"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1102: MAX Shear modulus"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1103: MAX Young modulus"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1104: MAX Poisson Modulus"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1105: MAX Pugh ratio"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1106: MAX Vickers hardness"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1107: MAX Fracture toughness"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1108: MAX Debye temperature"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1109: MAX Sound velocity"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1110: MAX S-wave velocity"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1111: MAX P-wave velocity"); + GUI_COMBOBOX_TABLE(table,uspex_gui.atomType,"atomType:",0,1,1,2); + GUI_COMBOBOX_ADD(uspex_gui.atomType,"ADD ATOMTYPE"); +GUI_TOOLTIP(uspex_gui.atomType,"atomType: Ch. 4.1 DEFAULT: none\nThis list regroups several tags:\natomType, numSpecies, and valences."); + uspex_gui._tmp_atom_typ=0;uspex_gui._tmp_atom_num=0;uspex_gui._tmp_atom_val=0; + GUI_ENTRY_TABLE(table,uspex_gui._atom_typ,uspex_gui._tmp_atom_typ,"%3i","@Typ:",1,2,1,2); +GUI_TOOLTIP(uspex_gui._atom_typ,"atomTyp: - DEFAULT: none\nAtomic number of current atom."); + GUI_ENTRY_TABLE(table,uspex_gui._atom_num,uspex_gui._tmp_atom_num,"%3i","@Num:",2,3,1,2); +GUI_TOOLTIP(uspex_gui._atom_num,"atomNum: - DEFAULT: none\nNumber of atoms of that type."); + GUI_ENTRY_TABLE(table,uspex_gui._atom_val,uspex_gui._tmp_atom_val,"%3i","@Val:",3,4,1,2); +GUI_TOOLTIP(uspex_gui._atom_val,"atomVal: - DEFAULT: auto\nValence of the current atom type.\nAutomatically determined if zero."); + GUI_2BUTTONS_TABLE(table,apply_atom,remove_atom,4,5,1,2); +/* 3rd line */ + GUI_COMBOBOX_TABLE(table,uspex_gui.goodBonds,"goodBonds:",0,1,2,3); + GUI_COMBOBOX_ADD(uspex_gui.goodBonds,"ADD GOODBOND"); +GUI_TOOLTIP(uspex_gui.goodBonds,"goodBonds: Ch. 4.1 DEFAULT: auto\nSet the minimum distance at which a bond is considered."); + GUI_TEXT_TABLE(table,uspex_gui._bond_d,uspex_gui._tmp_bond_d,"Bonds: ",1,2,2,3); +GUI_TOOLTIP(uspex_gui._bond_d,"Minimum bond distance between selected and others species."); + GUI_CHECK_TABLE(table,button,uspex_gui.auto_bonds,auto_bond_toggle,"AUTO_BONDS",3,4,2,3); +GUI_TOOLTIP(button,"Automatically determine bonds (recommended)."); + GUI_2BUTTONS_TABLE(table,apply_bonds,remove_bonds,4,5,2,3); +/* 4th line */ + GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,2,3,4); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1: MIN Enthalpy"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"2: MIN Volume"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"3: MAX Hardness"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"4: MAX Degree of order"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"5: MAX Structure difference"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"6: MAX Dielect. suscept."); + GUI_COMBOBOX_ADD(uspex_gui.optType,"7: MAX Band gap"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"8: MAX Dielectric gap"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"9: MAX Magnetization"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"10: MAX Structure quasientropy"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1101: MAX Bulk modulus"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1102: MAX Shear modulus"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1103: MAX Young modulus"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1104: MAX Poisson Modulus"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1105: MAX Pugh ratio"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1106: MAX Vickers hardness"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1107: MAX Fracture toughness"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1108: MAX Debye temperature"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1109: MAX Sound velocity"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1110: MAX S-wave velocity"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1111: MAX P-wave velocity"); GUI_TOOLTIP(uspex_gui.optType,"optType: Ch. 4.1 DEFAULT: 1(Enthalpy)\nSelect the properties to optimize."); + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMolecs",3,4,3,4);/*TODO: add function*/ +GUI_TOOLTIP(button,"checkMolecules: Ch. 4.1 DEFAULT: TRUE\nCheck and discard broken/merged molecules."); + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckConnect",4,5,3,4);/*TODO: add function*/ +GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardness and add connectivity in softmutation."); /* initialize */ GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); + GUI_COMBOBOX_SETUP(uspex_gui.calculationType,0,uspex_type_selected); GUI_COMBOBOX_SETUP(uspex_gui.optType,0,uspex_optimization_selected); + GUI_COMBOBOX_SETUP(uspex_gui.atomType,0,NULL);/*TODO: add function*/ + GUI_SPIN_SET(uspex_gui._calctype_dim,3.); mol_toggle(); var_toggle(); + GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,NULL);/*TODO: add function*/ + auto_bond_toggle(); /* --- end frame */ /*------------------*/ diff --git a/src/gui_uspex.h b/src/gui_uspex.h index f3358e7..e62ac43 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -53,17 +53,23 @@ struct uspex_calc_gui{ GUI_OBJ *calculationType; GUI_OBJ *_calctype_dim; gdouble _dim;/*absurd spin on double*/ - //_calctype_mol is auto-sync - //_calctype_var is auto-sync + GUI_OBJ *_calctype_mol; + GUI_OBJ *_calctype_var; GUI_OBJ *optType; - /*atoms definition: add/apply/remove*/ - GUI_OBJ *_atom_type; + /*atoms definition: apply/remove*/ + GUI_OBJ *atomType; + GUI_OBJ *_atom_typ; GUI_OBJ *_atom_num; - GUI_OBJ *_atom_valence; + GUI_OBJ *_atom_val; + /*temporary value*/ + gint _tmp_atom_typ; + gint _tmp_atom_num; + gint _tmp_atom_val; /*bond definition: apply/auto*/ GUI_OBJ *goodBonds; + GUI_OBJ *_bond_d; + gchar *_tmp_bond_d; gboolean auto_bonds; - GUI_OBJ *Bonds; /**/ //checkMolecules is auto-sync //checkConnectivity is auto-sync From 789882716778f8cc4cfc3f144596d9644fed0e4f Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 15 Aug 2018 19:18:35 +0900 Subject: [PATCH 24/56] gui_vasp: FIX & better poscar sync. --- src/gui_uspex.c | 76 +++++++++++++++++++-- src/gui_vasp.c | 177 ++++++++++++++++++++++++++---------------------- src/pak.h | 1 + 3 files changed, 167 insertions(+), 87 deletions(-) diff --git a/src/gui_uspex.c b/src/gui_uspex.c index dfa67bf..dd9d0a7 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -52,6 +52,7 @@ The GNU GPL can also be found at http://www.gnu.org #include "gui_uspex.h" extern struct sysenv_pak sysenv; +extern struct elem_pak elements[]; /*globals variables*/ struct uspex_calc_gui uspex_gui; @@ -59,11 +60,75 @@ struct uspex_calc_gui uspex_gui; /*************************/ /* initialize gui values */ /*************************/ -void gui_uspex_init(){ +void gui_uspex_init(struct model_pak *model){ + gint idx; uspex_gui.cur_page=USPEX_PAGE_SET_I; + /*get atom information if not available*/ + if(uspex_gui.calc.atomType==NULL){ + gint idx; + GSList *list; + struct core_pak *core; + /*first get the _nspecies*/ + list=find_unique(ELEMENT,model); + uspex_gui.calc._nspecies=(gint)g_slist_length(list); + uspex_gui.calc.atomType = g_malloc(uspex_gui.calc._nspecies*sizeof(gint)); + for (idx=0 ; list ; list=g_slist_next(list)){ + uspex_gui.calc.atomType[idx]=GPOINTER_TO_INT(list->data); + idx++; + } + g_slist_free(list); + /*fill the numType with information from current model*/ + if(uspex_gui.calc.numSpecies!=NULL) g_free(uspex_gui.calc.numSpecies); + uspex_gui.calc._var_nspecies=1;/*we don't automatically vary formula at that point*/ + uspex_gui.calc.numSpecies = g_malloc(uspex_gui.calc._nspecies*sizeof(gint)); + for(idx=0;idxcores ; list ; list=g_slist_next(list)){ + core=list->data; + if(core->atom_code==uspex_gui.calc.atomType[idx]) uspex_gui.calc.numSpecies[idx]++; + else { + idx++; + uspex_gui.calc.numSpecies[idx]++; + } + } + if(uspex_gui.calc.valences!=NULL) g_free(uspex_gui.calc.valences); + uspex_gui.calc.valences = g_malloc(uspex_gui.calc._nspecies*sizeof(gint)); + for(idx=0;idxbasename); @@ -753,7 +818,8 @@ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardnes GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); GUI_COMBOBOX_SETUP(uspex_gui.calculationType,0,uspex_type_selected); GUI_COMBOBOX_SETUP(uspex_gui.optType,0,uspex_optimization_selected); - GUI_COMBOBOX_SETUP(uspex_gui.atomType,0,NULL);/*TODO: add function*/ + populate_atomType(); + GUI_COMBOBOX_SETUP(uspex_gui.atomType,uspex_gui.calc._nspecies,NULL);/*TODO: add function*/ GUI_SPIN_SET(uspex_gui._calctype_dim,3.); mol_toggle(); var_toggle(); diff --git a/src/gui_vasp.c b/src/gui_vasp.c index 5a450f8..c9e1a0f 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -2411,105 +2411,118 @@ void parallel_eq(void){ /* sync poscar information */ /***************************/ void vasp_poscar_sync(){ - gchar *tamp; + GSList *list=NULL; + GSList *lp; + gint *zval,*ztmp; gchar *text; - gchar *text2; - gchar *tamp2; + gchar *tamp; gchar symbol[3]; - gint idx,jdx; - if(vasp_gui.poscar_dirty==FALSE) return;/*ne need to update*/ -/* pass_1: GROUP atom list by atom types */ + gint idx,jdx,kdx; + gint natoms; + gint nspecies; + gint spec; + gboolean have_changed; + if(vasp_gui.poscar_dirty==FALSE) return;/*no need to update*/ + /* get the new number of atoms */ idx=0; GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); + sscanf(text,"%*[^!]! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); + nspecies=1; + tamp=g_strdup(&(vasp_gui.calc.poscar_symbol[0])); + zval = g_malloc(sizeof(gint)); + zval[0]=elem_symbol_test(vasp_gui.calc.poscar_symbol); while(g_ascii_strcasecmp(text,"ADD atom")!=0){ - sscanf(text,"%*f %*f %*f %*c %*c %*c ! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); - g_free(text); + idx++; + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); + GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); + sscanf(text,"%*[^!]! atom: %*i (%[^)])",&(symbol[0])); + if(g_ascii_strcasecmp(vasp_gui.calc.poscar_symbol,symbol) == 0){ + /*same species*/ + }else{ + /*different species*/ + have_changed=FALSE; + spec=elem_symbol_test(symbol); + for(kdx=0;kdxdata; + sscanf(text,"%*[^!]! atom: %*i (%[^)])",&(vasp_gui.calc.poscar_symbol[0])); + for (lp=list ; lp ; lp=g_slist_next(lp)){ + text=lp->data; + tamp=g_strdup(text);/*to get some space*/ + sscanf(text,"%[^!]! atom: %*i (%[^)])",tamp,&(symbol[0])); + text=g_strdup_printf("%s! atom: %i (%s)",tamp,idx,symbol); + g_free(tamp); + GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms,text); idx++; - jdx++; - GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,idx); - GUI_COMBOBOX_GET_TEXT(vasp_gui.poscar_atoms,text); } - vasp_gui.calc.atoms_total=idx;/*so we have the total number of atoms*/ - /*we need to get the last jdx*/ - text=g_strdup_printf("%s %i",tamp2,jdx); - g_free(tamp2); - tamp2=text; - if(vasp_gui.calc.species_symbols!=NULL) g_free(vasp_gui.calc.species_symbols); - if(vasp_gui.calc.species_numbers!=NULL) g_free(vasp_gui.calc.species_numbers); - vasp_gui.calc.species_symbols=g_strdup(tamp); - g_free(tamp); - vasp_gui.calc.species_numbers=g_strdup(tamp2); - g_free(tamp2); - vasp_gui.poscar_dirty=FALSE; + GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms,"ADD atom");/*add "ADD atom"*/ + GUI_COMBOBOX_SET(vasp_gui.poscar_atoms,natoms); + /*update some properties*/ + vasp_gui.calc.atoms_total=natoms; + vasp_gui.calc.species_total=nspecies; + /*cleanup*/ + for (lp=list ; lp ; lp=g_slist_next(lp)){ + g_free(lp->data); + lp->data=NULL; + } + g_slist_free(list); + g_free(zval); } - /************************/ /* Switch notebook page */ /************************/ diff --git a/src/pak.h b/src/pak.h index ce22fc0..e862acc 100644 --- a/src/pak.h +++ b/src/pak.h @@ -1394,6 +1394,7 @@ void delay(gint); gint read_elem_data(FILE *, gint); gint write_elem_data(FILE *); +GSList *find_unique(gint mode, struct model_pak *model); void cmd_init(gint, gchar **); From 0d088072787b3d9cde9f593744042f14de473fe9 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 16 Aug 2018 18:13:21 +0900 Subject: [PATCH 25/56] gui_uspex: FIX gui_uspex I + FIX gui_vasp + ADD anti_opt (for reverse USPEX optimization). --- src/file_uspex.c | 11 +- src/file_uspex.h | 3 +- src/gui_uspex.c | 277 ++++++++++++++++++++++++++++++++++++++++------- src/gui_uspex.h | 2 + src/gui_vasp.c | 22 +++- 5 files changed, 267 insertions(+), 48 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index f423b50..c2e7c50 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -72,6 +72,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC._calctype_mol=FALSE; _UC._calctype_var=FALSE; _UC.optType=US_OT_ENTHALPY; + _UC.anti_opt=FALSE; _UC._nspecies=0; _UC.atomType=NULL; _UC._var_nspecies=0; @@ -329,6 +330,10 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); } if (find_in_string("optType",line) != NULL) { k=0;sscanf(line,"%i%*s",&(k)); + if(k<0) { + _UC.anti_opt=TRUE; + k*=-1; + } switch (k){ case 1: _UC.optType=US_OT_ENTHALPY; @@ -1011,6 +1016,7 @@ _CP(_calctype_dim); _CP(_calctype_mol); _CP(_calctype_var); _CP(optType); +_CP(anti_opt); _CP(_nspecies); _COPY(atomType,_SRC._nspecies,gint); _CP(_var_nspecies); @@ -1266,7 +1272,10 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ fprintf(vf,"???\t: calculationMethod (unsupported method)\n"); } __OUT_INT(calculationType); - __OUT_INT(optType); + if(_UC.anti_opt) __OUT_INT(optType); + else { + fprintf(vf,"%i\t: optType\n",-1*_UC.optType); + } __OUT_BK_INT(atomType,"EndAtomType",_UC._nspecies); if(_UC._var_nspecies==1){ __OUT_BK_INT(numSpecies,"EndNumSpecies",_UC._nspecies); diff --git a/src/file_uspex.h b/src/file_uspex.h index 05da289..d3b19ba 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -91,7 +91,8 @@ typedef struct { gint _calctype_dim; /*HIDDEN: X.. digit in calculation type: dimension*/ gboolean _calctype_mol; /*HIDDEN: .X. digit in calculation type: molecular*/ gboolean _calctype_var; /*HIDDEN: ..X digit in calculation type: variable composition*/ - uspex_opt optType; /* optimization property*/ + uspex_opt optType; /*optimization property*/ + gboolean anti_opt; /*if set, reverse the optimization direction*/ gint _nspecies; /*HIDDEN: number of different species*/ gint *atomType; /*atomic number of each species*/ gint _var_nspecies; /*HIDDEN: numer of numSpecies blocks*/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index dd9d0a7..cb1e855 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -61,7 +61,6 @@ struct uspex_calc_gui uspex_gui; /* initialize gui values */ /*************************/ void gui_uspex_init(struct model_pak *model){ - gint idx; uspex_gui.cur_page=USPEX_PAGE_SET_I; /*get atom information if not available*/ if(uspex_gui.calc.atomType==NULL){ @@ -82,13 +81,13 @@ void gui_uspex_init(struct model_pak *model){ uspex_gui.calc._var_nspecies=1;/*we don't automatically vary formula at that point*/ uspex_gui.calc.numSpecies = g_malloc(uspex_gui.calc._nspecies*sizeof(gint)); for(idx=0;idxcores ; list ; list=g_slist_next(list)){ + idx=0; core=list->data; - if(core->atom_code==uspex_gui.calc.atomType[idx]) uspex_gui.calc.numSpecies[idx]++; - else { + /*find corresponding species*/ + while(idxatom_code==uspex_gui.calc.atomType[idx]) uspex_gui.calc.numSpecies[idx]++; idx++; - uspex_gui.calc.numSpecies[idx]++; } } if(uspex_gui.calc.valences!=NULL) g_free(uspex_gui.calc.valences); @@ -116,7 +115,7 @@ void populate_atomType(void){ /*only update goodBonds if needed*/ if((uspex_gui.calc.goodBonds!=NULL)&&(uspex_gui.auto_bonds)){ for(idx=0;idx should never happen*/ + GUI_COMBOBOX_SET(uspex_gui.atomType,0); + return; + } + GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); + /*mini-sync*/ + GUI_REG_VAL(uspex_gui._atom_sym,sym[0],"%s"); + GUI_REG_VAL(uspex_gui._atom_num,num,"%i"); + GUI_REG_VAL(uspex_gui._atom_val,val,"%i"); + typ = elem_symbol_test(sym); + /*trick to have a valid sym*/ + strcpy(sym,elements[typ].symbol); + if (g_ascii_strcasecmp(text,"ADD ATOMTYPE") == 0) { + g_free(text); + /*add a new atomType*/ + /*check if atomType does not exists*/ + index=0; + GUI_COMBOBOX_SET(uspex_gui.atomType,0); + GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); + while(g_ascii_strcasecmp(text,"ADD ATOMTYPE") != 0){ + sscanf(text,"%[^(](%*i) (V=%*i)",tmp); + uspex_gui._tmp_atom_typ=elem_symbol_test(tmp); + if(uspex_gui._tmp_atom_typ==typ) exists=TRUE; + g_free(text); + index++; + GUI_COMBOBOX_SET(uspex_gui.atomType,index); + GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); + } + if(exists){ + text = g_strdup_printf("Atom type %s already exists! Can't add to atomType!\n",sym); + gui_text_show(ERROR,text); + g_free(text); + return; + }else{ + text = g_strdup_printf("%s(%i) (V=%i)",sym,num,val); + GUI_COMBOBOX_ADD_TEXT(uspex_gui.atomType,index,text); + GUI_COMBOBOX_SET(uspex_gui.atomType,index+1);/*select last*/ + g_free(text); + } + }else{ + /*get current typ*/ + sscanf(text,"%[^(](%*i) (V=%*i)",tmp); + uspex_gui._tmp_atom_typ = elem_symbol_test(tmp); + g_free(text); + /*modify an atomType*/ + if(typ!=uspex_gui._tmp_atom_typ){ + gint index_bkup; + /*type have changed, check if new type exists*/ + index_bkup=index;/*SAVE INDEX*/ + index=0; + GUI_COMBOBOX_SET(uspex_gui.atomType,0); + GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); + while(g_ascii_strcasecmp(text,"ADD ATOMTYPE") != 0){ + sscanf(text,"%[^(](%*i) (V=%*i)",tmp); + uspex_gui._tmp_atom_typ=elem_symbol_test(tmp); + if(uspex_gui._tmp_atom_typ==typ) exists=TRUE; + g_free(text); + index++; + GUI_COMBOBOX_SET(uspex_gui.atomType,index); + GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); + } + if(exists){ + text = g_strdup_printf("Atom type %s already exists! Can't modify atomType!\n",sym); + gui_text_show(ERROR,text); + g_free(text); + return; + } + index=index_bkup;/*RESTORE INDEX*/ + } + /*just update values*/ + text = g_strdup_printf("%s(%i) (V=%i)",sym,num,val); + GUI_COMBOBOX_ADD_TEXT(uspex_gui.atomType,index,text); + GUI_COMBOBOX_DEL(uspex_gui.atomType,index+1); + g_free(text); + } + /*select "ADD ATOM" (for convenience)*/ + GUI_COMBOBOX_SET(uspex_gui.atomType,index); + GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); + while(g_ascii_strcasecmp(text,"ADD ATOMTYPE") != 0){ + g_free(text); + index++; + GUI_COMBOBOX_SET(uspex_gui.atomType,index); + GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); + } + g_free(text); } /****************************************/ /* Remove selected atomType information */ /****************************************/ void remove_atom(){ -/*TODO*/ + gint index; + gchar *text; + GUI_COMBOBOX_GET(uspex_gui.atomType,index); + if(index==-1) {/*nothing selected -> should never happen*/ + GUI_COMBOBOX_SET(uspex_gui.atomType,0); + return; + } + GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); + if (g_ascii_strcasecmp(text,"ADD ATOMTYPE") == 0) { + /*can't delete this one*/ + g_free(text); + return; + } + GUI_COMBOBOX_DEL(uspex_gui.atomType,index); + if(index-1<0) index=1; + GUI_COMBOBOX_SET(uspex_gui.atomType,index-1); + g_free(text); } /*********************/ /* toggle auto_bonds */ @@ -485,17 +617,72 @@ void auto_bond_toggle(void){ GUI_UNLOCK(uspex_gui._bond_d); } } +/**********************/ +/* Selecting goodBond */ +/**********************/ +void goodBonds_selected(GUI_OBJ *w){ + gchar *text; + /**/ + GUI_COMBOBOX_GET_TEXT(w,text); + if (g_ascii_strcasecmp(text,"ADD GOODBOND") == 0) return;/*last selection*/ + /*the line is going directly into _bond_d*/ + if(uspex_gui._tmp_bond_d!=NULL) g_free(uspex_gui._tmp_bond_d); + uspex_gui._tmp_bond_d=g_strdup(text); + GUI_ENTRY_TEXT(uspex_gui._bond_d,uspex_gui._tmp_bond_d); + g_free(text); +} /************************************/ /* Change/ADD goodBonds information */ /************************************/ void apply_bonds(){ -/*TODO*/ + gint index; + gchar *text; + /**/ + GUI_COMBOBOX_GET(uspex_gui.goodBonds,index); + GUI_COMBOBOX_GET_TEXT(uspex_gui.goodBonds,text); + if(uspex_gui._tmp_bond_d!=NULL) g_free(uspex_gui._tmp_bond_d); + GUI_ENTRY_GET_TEXT(uspex_gui._bond_d,uspex_gui._tmp_bond_d); + GUI_COMBOBOX_ADD_TEXT(uspex_gui.goodBonds,index,uspex_gui._tmp_bond_d); + if (g_ascii_strcasecmp(text,"ADD GOODBOND") == 0){ + /*new line*/ + GUI_COMBOBOX_SET(uspex_gui.goodBonds,index+1); + }else{ + /*modify*/ + GUI_COMBOBOX_DEL(uspex_gui.goodBonds,index+1); + g_free(text); + /*select "ADD GOODBOND" (for convenience)*/ + GUI_COMBOBOX_SET(uspex_gui.goodBonds,index); + GUI_COMBOBOX_GET_TEXT(uspex_gui.goodBonds,text); + while(g_ascii_strcasecmp(text,"ADD GOODBOND") != 0){ + g_free(text); + index++; + GUI_COMBOBOX_SET(uspex_gui.goodBonds,index); + GUI_COMBOBOX_GET_TEXT(uspex_gui.goodBonds,text); + } + } + g_free(text); } /********************************/ /* Remove goodBonds information */ /********************************/ void remove_bonds(){ -/*TODO*/ + gint index; + gchar *text; + GUI_COMBOBOX_GET(uspex_gui.goodBonds,index); + if(index==-1) {/*nothing selected -> should never happen*/ + GUI_COMBOBOX_SET(uspex_gui.goodBonds,0); + return; + } + GUI_COMBOBOX_GET_TEXT(uspex_gui.goodBonds,text); + if (g_ascii_strcasecmp(text,"ADD GOODBOND") == 0){ + /*can't delete this one*/ + g_free(text); + return; + } + GUI_COMBOBOX_DEL(uspex_gui.goodBonds,index); + if(index-1<0) index=1; + GUI_COMBOBOX_SET(uspex_gui.goodBonds,index-1); + g_free(text); } @@ -505,7 +692,7 @@ void remove_bonds(){ /************************/ void uspex_gui_page_switch(GUI_NOTE *notebook,GUI_OBJ *page,guint page_num){ gint from_page; - gchar *text; +// gchar *text; /* some (few) values need to be updated from a page to another*/ GUI_NOTE_PAGE_NUMBER(notebook,from_page); if(from_page==(gint)page_num) return;/*not moved*/ @@ -536,7 +723,7 @@ void uspex_gui_sync(){ /***************************/ gint save_uspex_calc(){ #define DEBUG_USPEX_SAVE 0 - FILE *save_fp; +// FILE *save_fp; gchar *filename; /*1-synchronize*/ uspex_gui_sync(); @@ -668,11 +855,11 @@ void gui_uspex_dialog(void){ gpointer dialog; GUI_OBJ *frame, *vbox, *hbox, *table; GUI_OBJ *notebook, *page, *button, *label; - GUI_OBJ *separator; +// GUI_OBJ *separator; /* special */ struct model_pak *data; - struct core_pak *core; - gint idx; +// struct core_pak *core; +// gint idx; gchar *tmp; /* checks */ data = sysenv.active_model; @@ -738,7 +925,7 @@ GUI_TOOLTIP(uspex_gui.file_entry,"Use the previous result of a USPEX calculation /* --- Type & System */ GUI_FRAME_NOTE(page,frame,"Type & System"); /* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,5,4); + GUI_TABLE_FRAME(frame,table,6,4); /* 1st line */ GUI_COMBOBOX_TABLE(table,uspex_gui.calculationMethod,"calcMethod: ",0,1,0,1); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"USPEX"); @@ -746,7 +933,7 @@ GUI_TOOLTIP(uspex_gui.file_entry,"Use the previous result of a USPEX calculation GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"VCNEB"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"PSO"); GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: USPEX\nSet the method of calculation."); -GUI_COMBOBOX_TABLE(table,uspex_gui.calculationType,"calcType: ",1,2,0,1); + GUI_COMBOBOX_TABLE(table,uspex_gui.calculationType,"calcType: ",1,3,0,1); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"300"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"301"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"310"); @@ -757,44 +944,47 @@ GUI_COMBOBOX_TABLE(table,uspex_gui.calculationType,"calcType: ",1,2,0,1); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"201"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"-200"); GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationType: Ch. 4.1 DEFAULT: 300\nSets the dimensionality, molecularity, and variability\nof the calculation, can also be set individually.\n(311) and (110) calculations may not be supported."); - GUI_SPIN_TABLE(table,uspex_gui._calctype_dim,uspex_gui._dim,spin_update_dim,"DIM",2,3,0,1); + GUI_SPIN_TABLE(table,uspex_gui._calctype_dim,uspex_gui._dim,spin_update_dim,"DIM",3,4,0,1); GUI_SPIN_RANGE(uspex_gui._calctype_dim,-2.,3.); GUI_TOOLTIP(uspex_gui._calctype_dim,"Set the dimension of the system.\n3, 2, 1, and 0 are equilvalent to 3D, 2D, 1D, and 0D.\n-2 correspond to 2D crystals."); - GUI_CHECK_TABLE(table,uspex_gui._calctype_mol,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",3,4,0,1); + GUI_CHECK_TABLE(table,uspex_gui._calctype_mol,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",4,5,0,1); GUI_TOOLTIP(uspex_gui._calctype_mol,"Set the molecularity of the system."); - GUI_CHECK_TABLE(table,uspex_gui._calctype_var,uspex_gui.calc._calctype_var,var_toggle,"VAR",4,5,0,1); + GUI_CHECK_TABLE(table,uspex_gui._calctype_var,uspex_gui.calc._calctype_var,var_toggle,"VAR",5,6,0,1); GUI_TOOLTIP(uspex_gui._calctype_var,"Set the variability of chemical composition."); /* 2nd line */ GUI_COMBOBOX_TABLE(table,uspex_gui.atomType,"atomType:",0,1,1,2); GUI_COMBOBOX_ADD(uspex_gui.atomType,"ADD ATOMTYPE"); GUI_TOOLTIP(uspex_gui.atomType,"atomType: Ch. 4.1 DEFAULT: none\nThis list regroups several tags:\natomType, numSpecies, and valences."); uspex_gui._tmp_atom_typ=0;uspex_gui._tmp_atom_num=0;uspex_gui._tmp_atom_val=0; - GUI_ENTRY_TABLE(table,uspex_gui._atom_typ,uspex_gui._tmp_atom_typ,"%3i","@Typ:",1,2,1,2); -GUI_TOOLTIP(uspex_gui._atom_typ,"atomTyp: - DEFAULT: none\nAtomic number of current atom."); - GUI_ENTRY_TABLE(table,uspex_gui._atom_num,uspex_gui._tmp_atom_num,"%3i","@Num:",2,3,1,2); -GUI_TOOLTIP(uspex_gui._atom_num,"atomNum: - DEFAULT: none\nNumber of atoms of that type."); - GUI_ENTRY_TABLE(table,uspex_gui._atom_val,uspex_gui._tmp_atom_val,"%3i","@Val:",3,4,1,2); -GUI_TOOLTIP(uspex_gui._atom_val,"atomVal: - DEFAULT: auto\nValence of the current atom type.\nAutomatically determined if zero."); - GUI_2BUTTONS_TABLE(table,apply_atom,remove_atom,4,5,1,2); + strcpy(uspex_gui._tmp_atom_sym,elements[uspex_gui._tmp_atom_typ].symbol); + GUI_ENTRY_TABLE(table,uspex_gui._atom_sym,uspex_gui._tmp_atom_sym,"%s","@Sym:",1,2,1,2); +GUI_TOOLTIP(uspex_gui._atom_sym,"atomSym: - DEFAULT: none\nAtomic symbol of current species."); + GUI_ENTRY_TABLE(table,uspex_gui._atom_typ,uspex_gui._tmp_atom_typ,"%3i","@Typ:",2,3,1,2); +GUI_TOOLTIP(uspex_gui._atom_typ,"atomTyp: - DEFAULT: none\nAtomic number of current species."); + GUI_ENTRY_TABLE(table,uspex_gui._atom_num,uspex_gui._tmp_atom_num,"%3i","@Num:",3,4,1,2); +GUI_TOOLTIP(uspex_gui._atom_num,"atomNum: - DEFAULT: none\nNumber of atoms in current species."); + GUI_ENTRY_TABLE(table,uspex_gui._atom_val,uspex_gui._tmp_atom_val,"%3i","@Val:",4,5,1,2); +GUI_TOOLTIP(uspex_gui._atom_val,"atomVal: - DEFAULT: auto\nValence of the current species.\nAutomatically determined if zero."); + GUI_2BUTTONS_TABLE(table,apply_atom,remove_atom,5,6,1,2); /* 3rd line */ GUI_COMBOBOX_TABLE(table,uspex_gui.goodBonds,"goodBonds:",0,1,2,3); GUI_COMBOBOX_ADD(uspex_gui.goodBonds,"ADD GOODBOND"); GUI_TOOLTIP(uspex_gui.goodBonds,"goodBonds: Ch. 4.1 DEFAULT: auto\nSet the minimum distance at which a bond is considered."); - GUI_TEXT_TABLE(table,uspex_gui._bond_d,uspex_gui._tmp_bond_d,"Bonds: ",1,2,2,3); + GUI_TEXT_TABLE(table,uspex_gui._bond_d,uspex_gui._tmp_bond_d,"Bonds: ",1,4,2,3); GUI_TOOLTIP(uspex_gui._bond_d,"Minimum bond distance between selected and others species."); - GUI_CHECK_TABLE(table,button,uspex_gui.auto_bonds,auto_bond_toggle,"AUTO_BONDS",3,4,2,3); + GUI_CHECK_TABLE(table,button,uspex_gui.auto_bonds,auto_bond_toggle,"AUTO_BONDS",4,5,2,3); GUI_TOOLTIP(button,"Automatically determine bonds (recommended)."); - GUI_2BUTTONS_TABLE(table,apply_bonds,remove_bonds,4,5,2,3); + GUI_2BUTTONS_TABLE(table,apply_bonds,remove_bonds,5,6,2,3); /* 4th line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,2,3,4); - GUI_COMBOBOX_ADD(uspex_gui.optType,"1: MIN Enthalpy"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"2: MIN Volume"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"3: MAX Hardness"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"4: MAX Degree of order"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"5: MAX Structure difference"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"6: MAX Dielect. suscept."); + GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,3,3,4); + GUI_COMBOBOX_ADD(uspex_gui.optType,"1: MIN Enthalpy (stable phases)"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"2: MIN Volume (densest structure)"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"3: MAX Hardness (hardest phase)"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"4: MAX order (most order structure)"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"5: MAX Structure average difference"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"6: MAX Dielectric susceptibility"); GUI_COMBOBOX_ADD(uspex_gui.optType,"7: MAX Band gap"); - GUI_COMBOBOX_ADD(uspex_gui.optType,"8: MAX Dielectric gap"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"8: MAX electric energy storage capacity"); GUI_COMBOBOX_ADD(uspex_gui.optType,"9: MAX Magnetization"); GUI_COMBOBOX_ADD(uspex_gui.optType,"10: MAX Structure quasientropy"); GUI_COMBOBOX_ADD(uspex_gui.optType,"1101: MAX Bulk modulus"); @@ -809,21 +999,24 @@ GUI_TOOLTIP(button,"Automatically determine bonds (recommended)."); GUI_COMBOBOX_ADD(uspex_gui.optType,"1110: MAX S-wave velocity"); GUI_COMBOBOX_ADD(uspex_gui.optType,"1111: MAX P-wave velocity"); GUI_TOOLTIP(uspex_gui.optType,"optType: Ch. 4.1 DEFAULT: 1(Enthalpy)\nSelect the properties to optimize."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMolecs",3,4,3,4);/*TODO: add function*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.anti_opt,NULL,"ANTI-OPT",3,4,3,4);/*not calling anything*/ +GUI_TOOLTIP(button,"anti-opt: - DEFAULT: FALSE\nIf set REVERSE the direction of optimization.\ni.e. MIN -> MAX & MAX -> MIN"); + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMolecs",4,5,3,4);/*not calling anything*/ GUI_TOOLTIP(button,"checkMolecules: Ch. 4.1 DEFAULT: TRUE\nCheck and discard broken/merged molecules."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckConnect",4,5,3,4);/*TODO: add function*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckConnect",5,6,3,4);/*not calling anything*/ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardness and add connectivity in softmutation."); /* initialize */ GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); GUI_COMBOBOX_SETUP(uspex_gui.calculationType,0,uspex_type_selected); GUI_COMBOBOX_SETUP(uspex_gui.optType,0,uspex_optimization_selected); + GUI_LOCK(uspex_gui._atom_typ); populate_atomType(); - GUI_COMBOBOX_SETUP(uspex_gui.atomType,uspex_gui.calc._nspecies,NULL);/*TODO: add function*/ + GUI_COMBOBOX_SETUP(uspex_gui.atomType,uspex_gui.calc._nspecies,atomType_selected); GUI_SPIN_SET(uspex_gui._calctype_dim,3.); mol_toggle(); var_toggle(); - GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,NULL);/*TODO: add function*/ + GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,goodBonds_selected); auto_bond_toggle(); /* --- end frame */ diff --git a/src/gui_uspex.h b/src/gui_uspex.h index e62ac43..3019919 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -58,10 +58,12 @@ struct uspex_calc_gui{ GUI_OBJ *optType; /*atoms definition: apply/remove*/ GUI_OBJ *atomType; + GUI_OBJ *_atom_sym; GUI_OBJ *_atom_typ; GUI_OBJ *_atom_num; GUI_OBJ *_atom_val; /*temporary value*/ + gchar _tmp_atom_sym[3]; gint _tmp_atom_typ; gint _tmp_atom_num; gint _tmp_atom_val; diff --git a/src/gui_vasp.c b/src/gui_vasp.c index c9e1a0f..86f108e 100644 --- a/src/gui_vasp.c +++ b/src/gui_vasp.c @@ -52,6 +52,7 @@ The GNU GPL can also be found at http://www.gnu.org #include "gui_vasp.h" extern struct sysenv_pak sysenv; +extern struct elem_pak elements[]; /*globals variables*/ struct vasp_calc_gui vasp_gui; @@ -3102,6 +3103,20 @@ void gui_vasp_dialog(void){ /* checks */ data = sysenv.active_model; if (!data) return; +/* some format can't be used */ + if (data->id == MORPH){ + title = g_strdup_printf("Can't setup a VASP calculation from a MORPH file!\n"); + gui_text_show(ERROR,title); + g_free(title); + return; + } +/* need natoms >1 */ + if (data->num_atoms==0) { + title = g_strdup_printf("Can't setup a VASP calculation with no atom information!\n"); + gui_text_show(ERROR,title); + g_free(title); + return; + } /* do we have a vasprun.xml model? */ if (data->id == VASP) { vasp_gui.have_xml=TRUE; @@ -3776,10 +3791,9 @@ GUI_TOOLTIP(vasp_gui.poscar_tx,"Tag for the motion of current ion\nin third latt for (list2=data->cores ; list2 ; list2=g_slist_next(list2)){ gchar sym[3]; core=list2->data; - sym[0]=core->atom_label[0]; - if(g_ascii_islower(core->atom_label[1])) sym[1]=core->atom_label[1]; - else sym[1]='\0'; - sym[2]='\0'; +//////////////// NEW: necessary for some unconventional atom definition: for ex. MG (instead of Mg). + strcpy(sym,elements[core->atom_code].symbol); +//////////////// if(vasp_gui.calc.poscar_free==VPF_FIXED){ GUI_COMBOBOX_ADD(vasp_gui.poscar_atoms, g_strdup_printf("%.8lf %.8lf %.8lf F F F ! atom: %i (%s)",core->x[0],core->x[1],core->x[2],idx,sym)); From a45d86cf5f7676783c8b9fe5ad96bddda2cae316 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 17 Aug 2018 02:16:50 +0900 Subject: [PATCH 26/56] gui_uspex: gui_uspex II. --- src/gui_uspex.c | 27 ++++++++++++++++++++++++++- src/gui_uspex.h | 6 ++++-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/gui_uspex.c b/src/gui_uspex.c index cb1e855..9265655 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -95,6 +95,15 @@ void gui_uspex_init(struct model_pak *model){ for(idx=0;idxnum_atoms%10)*10; + uspex_gui.calc.initialPopSize=uspex_gui.calc.populationSize; + } + if(uspex_gui.calc.stopCrit==0) { + if(uspex_gui.calc._calctype_var) uspex_gui.calc.stopCrit=uspex_gui.calc.maxAt; + else uspex_gui.calc.stopCrit=model->num_atoms; + } uspex_gui.is_dirty=TRUE; } /*****************************************************/ @@ -1005,7 +1014,6 @@ GUI_TOOLTIP(button,"anti-opt: - DEFAULT: FALSE\nIf set REVERSE the direction of GUI_TOOLTIP(button,"checkMolecules: Ch. 4.1 DEFAULT: TRUE\nCheck and discard broken/merged molecules."); GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckConnect",5,6,3,4);/*not calling anything*/ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardness and add connectivity in softmutation."); - /* initialize */ GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); GUI_COMBOBOX_SETUP(uspex_gui.calculationType,0,uspex_type_selected); @@ -1019,6 +1027,23 @@ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardnes GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,goodBonds_selected); auto_bond_toggle(); /* --- end frame */ +/* --- Population */ + GUI_FRAME_NOTE(page,frame,"Population"); +/* create a table in the frame*/ + GUI_TABLE_FRAME(frame,table,4,1); +/* 1st line */ + GUI_ENTRY_TABLE(table,uspex_gui.populationSize,uspex_gui.calc.populationSize,"%4i","SIZE:",0,1,0,1); +GUI_TOOLTIP(uspex_gui.populationSize,"populationSize: Ch. 4.2 DEFAULT: auto\nNumber of structures in each generation."); + GUI_ENTRY_TABLE(table,uspex_gui.initialPopSize,uspex_gui.calc.initialPopSize,"%4i","INIT_SZ:",1,2,0,1); +GUI_TOOLTIP(uspex_gui.populationSize,"initialPopSize: Ch. 4.2 DEFAULT: populationSize\nNumber of structures in initial generation."); + GUI_ENTRY_TABLE(table,uspex_gui.numGenerations,uspex_gui.calc.numGenerations,"%4i","N_GENE:",2,3,0,1); +GUI_TOOLTIP(uspex_gui.numGenerations,"numGenerations: Ch. 4.2 DEFAULT: 100\nMaximum number of generations."); + GUI_ENTRY_TABLE(table,uspex_gui.stopCrit,uspex_gui.calc.stopCrit,"%4i","STOP_CRIT:",3,4,0,1); +GUI_TOOLTIP(uspex_gui.stopCrit,"stopCrit: Ch. 4.2 DEFAULT: auto\nMaximum number of generations."); +/* --- end frame */ + + + /*------------------*/ /* page 2 -> SET-II */ diff --git a/src/gui_uspex.h b/src/gui_uspex.h index 3019919..7afa52a 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -76,8 +76,10 @@ struct uspex_calc_gui{ //checkMolecules is auto-sync //checkConnectivity is auto-sync /*4.2 Population*/ - - + GUI_OBJ *populationSize; + GUI_OBJ *initialPopSize; + GUI_OBJ *numGenerations; + GUI_OBJ *stopCrit; /* CALCUL */ GUI_OBJ *job_uspex_exe; GUI_OBJ *job_path; From cb6d253c1f9c2dfbec514598057f3bbd09f0cde8 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 17 Aug 2018 12:07:48 +0900 Subject: [PATCH 27/56] gui_uspex: gui_uspex III. --- src/gui_uspex.c | 17 +++++++++++++++++ src/gui_uspex.h | 5 +++++ 2 files changed, 22 insertions(+) diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 9265655..33a4927 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -104,6 +104,8 @@ void gui_uspex_init(struct model_pak *model){ if(uspex_gui.calc._calctype_var) uspex_gui.calc.stopCrit=uspex_gui.calc.maxAt; else uspex_gui.calc.stopCrit=model->num_atoms; } + if(uspex_gui.calc.keepBestHM==0) uspex_gui.calc.keepBestHM=(gint)(0.15*(uspex_gui.calc.populationSize)); + uspex_gui.is_dirty=TRUE; } /*****************************************************/ @@ -1041,6 +1043,21 @@ GUI_TOOLTIP(uspex_gui.numGenerations,"numGenerations: Ch. 4.2 DEFAULT: 100\nMaxi GUI_ENTRY_TABLE(table,uspex_gui.stopCrit,uspex_gui.calc.stopCrit,"%4i","STOP_CRIT:",3,4,0,1); GUI_TOOLTIP(uspex_gui.stopCrit,"stopCrit: Ch. 4.2 DEFAULT: auto\nMaximum number of generations."); /* --- end frame */ +/* --- Survival & Selection */ + GUI_FRAME_NOTE(page,frame,"Survival & Selection"); +/* create a table in the frame*/ + GUI_TABLE_FRAME(frame,table,4,1); +/* 1st line */ + GUI_ENTRY_TABLE(table,uspex_gui.bestFrac,uspex_gui.calc.bestFrac,"%.5f","BestFrac:",0,1,0,1); +GUI_TOOLTIP(uspex_gui.bestFrac,"populationSize: Ch. 4.3 DEFAULT: 0.7\nFraction of current generation used to generate the next."); + GUI_ENTRY_TABLE(table,uspex_gui.keepBestHM,uspex_gui.calc.keepBestHM,"%3i","keepBestHM:",1,2,0,1); +GUI_TOOLTIP(uspex_gui.keepBestHM,"keepBestHM: Ch. 4.3 DEFAULT: auto\nNumber of best structures that will survive in next generation."); + GUI_CHECK_TABLE(table,button,uspex_gui.calc.reoptOld,NULL,"reoptOld",2,3,0,1);/*not calling anything*/ +GUI_TOOLTIP(button,"reoptOld: Ch. 4.3 DEFAULT: FALSE\nIf set surviving structure will be re-optimized."); +/* --- end frame */ + + + diff --git a/src/gui_uspex.h b/src/gui_uspex.h index 7afa52a..0c2a33b 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -80,6 +80,11 @@ struct uspex_calc_gui{ GUI_OBJ *initialPopSize; GUI_OBJ *numGenerations; GUI_OBJ *stopCrit; +/*4.3 Survival of the fittest & Selection*/ + GUI_OBJ *bestFrac; + GUI_OBJ *keepBestHM; + GUI_OBJ *reoptOld; + /* CALCUL */ GUI_OBJ *job_uspex_exe; GUI_OBJ *job_path; From 9d0612bf1706d3a7ef467eb514ef7d84bda6fbb3 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 17 Aug 2018 20:06:22 +0900 Subject: [PATCH 28/56] gui_uspex: gui_uspex IV + FIX uspex Parameters READ. --- src/file_uspex.c | 151 +++++++++++++++++++++++++++------------- src/file_uspex.h | 3 +- src/gui_uspex.c | 175 ++++++++++++++++++++++++++++++++++++++++++++--- src/gui_uspex.h | 15 ++++ 4 files changed, 285 insertions(+), 59 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index c2e7c50..78fa096 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -65,6 +65,8 @@ extern struct elem_pak elements[]; void init_uspex_parameters(uspex_calc_struct *uspex_calc){ /*Initialize uspex_calc with model independant parameters.*/ _UC.name=NULL; + _UC.filename=NULL; + _UC.path=NULL; _UC.special=0; _UC.calculationMethod=US_CM_USPEX; _UC.calculationType=300; @@ -203,7 +205,7 @@ void free_uspex_parameters(uspex_calc_struct *uspex_calc){ /************************************************************************/ /* Read Parameters.txt and fill keywords of uspex_calc_struct structure */ /************************************************************************/ -uspex_calc_struct *read_uspex_parameters(gchar *filename){ +uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ FILE *vf; long int vfpos; gchar *line=NULL; @@ -219,21 +221,7 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename){ uspex_calc = g_malloc(sizeof(uspex_calc_struct)); init_uspex_parameters(uspex_calc); /*some lazy defines*/ -#define __NSPECIES(line) do{\ - if(_UC._nspecies==0){\ - ptr=&(line[0]);\ - while(*ptr==' ') ptr++;\ - _UC._nspecies=1;\ - while(*ptr!='\0'){\ - if(*ptr==' ') {\ - _UC._nspecies++;ptr++;\ - while(g_ascii_isgraph(*ptr)) ptr++;\ - }else ptr++;\ - }\ - }\ -}while(0) #define __Q(a) #a - #define __GET_BOOL(value) if (find_in_string(__Q(value),line)!=NULL){\ k=0;sscanf(line,"%i%*s",&(k));\ _UC.value=(k==1);\ @@ -266,6 +254,74 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename){ } line = file_read_line(vf); +/* +++ 1st PASS: get important numbers*/ + while(line){ + if (find_in_string("atomType",line) !=NULL){ + g_free(line);line = file_read_line(vf);/*go next line*/ + ptr=&(line[0]); + while(*ptr==' ') ptr++; + _UC._nspecies=1; + while(*ptr!='\0'){ + if(*ptr==' ') { + _UC._nspecies++;ptr++; + while(g_ascii_isgraph(*ptr)) ptr++; + }else ptr++; + } + g_free(line);line = file_read_line(vf);/*this is the EndAtomType line*/ + g_free(line);line = file_read_line(vf); + continue; + } +if((find_in_string("abinitioCode",line)!=NULL)||(find_in_string("KresolStart",line)!=NULL)||(find_in_string("vacuumSize",line)!=NULL)){ + /*FIXME: there seems to be no way to get the number of optimization step (_num_opt_steps): + * abinitioCode -> can be only one value + * KresolStart -> can be omitted + * vacuumSize -> can be less than _num_opt_steps, also can be omitted + * commandExecutable -> can be less than _num_opt_steps */ + g_free(line);line = file_read_line(vf); + ptr=&(line[0]); + while(*ptr==' ') ptr++; + i=1; + while(*ptr!='\0'){ + if(*ptr==' ') { + i++;ptr++; + while(g_ascii_isgraph(*ptr)) ptr++; + }else ptr++; + } + if(i>_UC._num_opt_steps) _UC._num_opt_steps=i; + g_free(line);line = file_read_line(vf); + g_free(line);line = file_read_line(vf); + continue; + } + if(find_in_string("commandExecutable",line) != NULL){ + /*count the number of lines before EndExecutable, and hope it does represent _num_opt_steps*/ + i=0; + while(find_in_string("EndExecutable",line) == NULL){ + i++; + g_free(line);line = file_read_line(vf); + } + if(i>_UC._num_opt_steps) _UC._num_opt_steps=i; + g_free(line);line = file_read_line(vf); + continue; + } + /*no catch*/ + g_free(line);line = file_read_line(vf); + } + g_free(line); + if(_UC._nspecies==0){/*this one is mandatory*/ + if(safe_nspecies==0){ + line = g_strdup_printf("ERROR: Can't read USPEX output: no atom information!\n"); + gui_text_show(ERROR, line); + g_free(line); + fclose(vf); + return(NULL); + }else{ + /*this should *not* be the way to obtain _nspecies, atomType is mandatory!*/ + _UC._nspecies=safe_nspecies; + } + } + rewind(vf); +/* +++ 2nd PASS: get everything*/ + line = file_read_line(vf); while(line){ #if DEBUG_USPEX_READ fprintf(stdout,"#DBG: PROBE LINE: %s",line); @@ -308,6 +364,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); } _UC._calctype_dim=i; j-=i*100; + if(j<0) j*=-1; i=((int)(j/10))%10; if((i<0)||(i>1)){ g_free(line); @@ -407,8 +464,6 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); } if (find_in_string("atomType",line) !=NULL){ g_free(line);line = file_read_line(vf);/*go next line*/ - /*if no _nspecies, get it now*/ - __NSPECIES(line); /*look for atomType*/ _UC.atomType = g_malloc(_UC._nspecies*sizeof(gint)); for(i=0;i<_UC._nspecies;i++) _UC.atomType[i]=0; @@ -432,8 +487,6 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); if (find_in_string("numSpecies",line) != NULL) { vfpos=ftell(vf);/* flag */ g_free(line);line = file_read_line(vf);/*go next line*/ - /*if no _nspecies, get it now*/ - __NSPECIES(line); /*1st get the total number of lines*/ _UC._var_nspecies=0; do{ @@ -463,8 +516,6 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); __GET_DOUBLE(ExternalPressure) if (find_in_string("valences",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ - /*if no _nspecies, get it now*/ - __NSPECIES(line); /*look for valences*/ _UC.valences = g_malloc(_UC._nspecies*sizeof(gint)); for(i=0;i<_UC._nspecies;i++) _UC.valences[i]=0; @@ -483,8 +534,6 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); } if (find_in_string("goodBonds",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ - /*if no _nspecies, get it now*/ - __NSPECIES(line); /*look for goodBonds*/ _UC.goodBonds = g_malloc(_UC._nspecies*_UC._nspecies*sizeof(gdouble)); for(i=0;i<_UC._nspecies*_UC._nspecies;i++) _UC.goodBonds[i]=0.; @@ -530,8 +579,6 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); __GET_BOOL(minVectorLength); if (find_in_string("IonDistances",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ - /*if no _nspecies, get it now*/ - __NSPECIES(line); /*look for IonDistances*/ _UC.IonDistances = g_malloc(_UC._nspecies*_UC._nspecies*sizeof(gdouble)); for(i=0;i<_UC._nspecies*_UC._nspecies;i++) _UC.IonDistances[i]=0.; @@ -700,16 +747,6 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); } if (find_in_string("abinitioCode",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ - /*count number of optimization steps*/ - ptr=&(line[0]); - while(*ptr==' ') ptr++; - _UC._num_opt_steps=1; - while(*ptr!='\0'){ - if(*ptr==' ') { - _UC._num_opt_steps++;ptr++; - while(g_ascii_isgraph(*ptr)) ptr++; - }else ptr++; - }/*note that the METADYNAMICS parenthesis are ignored as well*/ /*look for abinitioCode*/ _UC.abinitioCode = g_malloc(_UC._num_opt_steps*sizeof(gint)); for(i=0;i<_UC._num_opt_steps;i++) _UC.abinitioCode[i]=0; @@ -746,9 +783,9 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); } if (find_in_string("vacuumSize",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ - /*in my understanding, there is also either 1 or _num_opt_steps values of vacuumSize*/ + /*in my understanding, there is BETWEEN 1 to _num_opt_steps values of vacuumSize*/ _UC.vacuumSize = g_malloc(_UC._num_opt_steps*sizeof(gdouble)); - for(i=0;i<_UC._num_opt_steps;i++) _UC.vacuumSize[i]=0.; + for(i=0;i<_UC._num_opt_steps;i++) _UC.vacuumSize[i]=10.;/*implicit is 10.*/ ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ @@ -765,7 +802,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); __GET_INT(numParallelCalcs); if (find_in_string("commandExecutable",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ - /*there is 1-1){ fclose(vf);vf=NULL; /* --- READ Parameters.txt */ aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); - _UO.calc=read_uspex_parameters(aux_file); + _UO.calc=read_uspex_parameters(aux_file,num); if(_UO.calc==NULL){ line = g_strdup_printf("ERROR: reading USPEX REAL Parameter.txt file!\n"); gui_text_show(ERROR, line); @@ -1817,6 +1869,7 @@ if(job>-1){ } g_free(aux_file); uspex_calc=_UO.calc; + _UC.path=g_strdup(res_folder); /* --- CHECK type from Parameters.txt matches that of OUTPUT.TXT */ if((job!=-1)&&(job!=_UC.calculationType)){ /*since VCNEB will fail here due to a non-unified OUTPUT.txt format @@ -1826,8 +1879,6 @@ if(job>-1){ g_free(line); goto uspex_fail; } - /*special case: no nspecies information*/ - if(_UC._nspecies==0) _UC._nspecies=num; if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ /* --- if calculationMethod={USPEX,META} */ g_free(model->basename);/*FIX: _VALGRIND_BUG_*/ @@ -2442,6 +2493,8 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i } /*g_free some data*/ g_free(res_folder); + /*update some properties*/ + model->num_species=_UO.calc->_nspecies; /*end*/ error_table_print_all(); diff --git a/src/file_uspex.h b/src/file_uspex.h index d3b19ba..25fcd9e 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -83,6 +83,7 @@ typedef struct { typedef struct { /*additional controls*/ gchar *name; /*the job name*/ + gchar *path; /*job path*/ gchar *filename; /*corresponding filename*/ gint special; /*special tag*/ /*4.1 Type of run & System*/ @@ -274,7 +275,7 @@ typedef struct { /*methods of interest*/ void init_uspex_parameters(uspex_calc_struct *uspex_calc); void free_uspex_parameters(uspex_calc_struct *uspex_calc); -uspex_calc_struct *read_uspex_parameters(gchar *filename); +uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies); void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest); gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc); diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 33a4927..df56ed7 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -61,10 +61,10 @@ struct uspex_calc_gui uspex_gui; /* initialize gui values */ /*************************/ void gui_uspex_init(struct model_pak *model){ + gint idx; uspex_gui.cur_page=USPEX_PAGE_SET_I; /*get atom information if not available*/ if(uspex_gui.calc.atomType==NULL){ - gint idx; GSList *list; struct core_pak *core; /*first get the _nspecies*/ @@ -94,6 +94,11 @@ void gui_uspex_init(struct model_pak *model){ uspex_gui.calc.valences = g_malloc(uspex_gui.calc._nspecies*sizeof(gint)); for(idx=0;idxnum_atoms; } if(uspex_gui.calc.keepBestHM==0) uspex_gui.calc.keepBestHM=(gint)(0.15*(uspex_gui.calc.populationSize)); - + if(uspex_gui.calc.symmetries==NULL){ + switch(uspex_gui.calc._calctype_dim){ + case 0: + uspex_gui.calc.symmetries=g_strdup("E C2 D2 C4 C3 C6 T S2 Ch1 Cv2 S4 S6 Ch3 Th Ch2 Ch4 D3 Ch6 O D4 Cv3 D6 Td Cv4 Dd3 Cv6 Oh C5 S5 S10 Cv5 Ch5 D5 Dd5 Dh5 I Ih"); + break; + case 1: + uspex_gui.calc.symmetries=g_strdup(""); + break; + case 2: + uspex_gui.calc.symmetries=g_strdup("2-17"); + break; + case 3: + default: + uspex_gui.calc.symmetries=g_strdup("2-230"); + } + } + if((uspex_gui.calc.fracPerm==0)&&(uspex_gui.calc._nspecies>1)) uspex_gui.calc.fracPerm=0.1; + if((uspex_gui.calc.fracRotMut==0)&&(uspex_gui.calc._calctype_mol)) uspex_gui.calc.fracRotMut=0.1; + if((uspex_gui.calc.fracLatMut==0)&&(uspex_gui.calc.optRelaxType!=1)) uspex_gui.calc.fracLatMut=0.1; + if((uspex_gui.calc.howManySwaps==0)&&(uspex_gui.calc._nspecies>1)){ + if(uspex_gui.calc.specificSwaps==NULL){ + gint i,j; + for(i=0;i<(uspex_gui.calc._nspecies-1);i++) + for(j=i+1;jfilename); + /*be careful to read Parameters.txt, specifically*/ + title = g_strdup_printf("%s%s",_UO.calc->path,"Parameters.txt"); + uspex_calc = read_uspex_parameters(title,data->num_species); + g_free(title); if(uspex_calc){ uspex_gui.have_output=TRUE; copy_uspex_parameters(uspex_calc,&(uspex_gui.calc)); @@ -915,7 +1021,7 @@ GUI_TOOLTIP(uspex_gui.name,"The model name will be used in USPEX files\nas well GUI_LABEL_BOX(hbox,label,"CONNECTED OUTPUT"); if(uspex_gui.have_output){ uspex_output_struct *uspex_output=data->uspex; - tmp=g_strdup_printf("%s",_UO.calc->filename); + tmp=g_strdup_printf("%s%s",_UO.calc->path,"Parameters.txt"); GUI_TEXT_ENTRY(hbox,uspex_gui.file_entry,tmp,TRUE); g_free(tmp); }else{ @@ -1023,7 +1129,7 @@ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardnes GUI_LOCK(uspex_gui._atom_typ); populate_atomType(); GUI_COMBOBOX_SETUP(uspex_gui.atomType,uspex_gui.calc._nspecies,atomType_selected); - GUI_SPIN_SET(uspex_gui._calctype_dim,3.); + GUI_SPIN_SET(uspex_gui._calctype_dim,(gdouble) uspex_gui.calc._calctype_dim); mol_toggle(); var_toggle(); GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,goodBonds_selected); @@ -1037,7 +1143,7 @@ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardnes GUI_ENTRY_TABLE(table,uspex_gui.populationSize,uspex_gui.calc.populationSize,"%4i","SIZE:",0,1,0,1); GUI_TOOLTIP(uspex_gui.populationSize,"populationSize: Ch. 4.2 DEFAULT: auto\nNumber of structures in each generation."); GUI_ENTRY_TABLE(table,uspex_gui.initialPopSize,uspex_gui.calc.initialPopSize,"%4i","INIT_SZ:",1,2,0,1); -GUI_TOOLTIP(uspex_gui.populationSize,"initialPopSize: Ch. 4.2 DEFAULT: populationSize\nNumber of structures in initial generation."); +GUI_TOOLTIP(uspex_gui.initialPopSize,"initialPopSize: Ch. 4.2 DEFAULT: populationSize\nNumber of structures in initial generation."); GUI_ENTRY_TABLE(table,uspex_gui.numGenerations,uspex_gui.calc.numGenerations,"%4i","N_GENE:",2,3,0,1); GUI_TOOLTIP(uspex_gui.numGenerations,"numGenerations: Ch. 4.2 DEFAULT: 100\nMaximum number of generations."); GUI_ENTRY_TABLE(table,uspex_gui.stopCrit,uspex_gui.calc.stopCrit,"%4i","STOP_CRIT:",3,4,0,1); @@ -1049,12 +1155,63 @@ GUI_TOOLTIP(uspex_gui.stopCrit,"stopCrit: Ch. 4.2 DEFAULT: auto\nMaximum number GUI_TABLE_FRAME(frame,table,4,1); /* 1st line */ GUI_ENTRY_TABLE(table,uspex_gui.bestFrac,uspex_gui.calc.bestFrac,"%.5f","BestFrac:",0,1,0,1); -GUI_TOOLTIP(uspex_gui.bestFrac,"populationSize: Ch. 4.3 DEFAULT: 0.7\nFraction of current generation used to generate the next."); +GUI_TOOLTIP(uspex_gui.bestFrac,"bestFrac: Ch. 4.3 DEFAULT: 0.7\nFraction of current generation used to generate the next."); GUI_ENTRY_TABLE(table,uspex_gui.keepBestHM,uspex_gui.calc.keepBestHM,"%3i","keepBestHM:",1,2,0,1); GUI_TOOLTIP(uspex_gui.keepBestHM,"keepBestHM: Ch. 4.3 DEFAULT: auto\nNumber of best structures that will survive in next generation."); GUI_CHECK_TABLE(table,button,uspex_gui.calc.reoptOld,NULL,"reoptOld",2,3,0,1);/*not calling anything*/ GUI_TOOLTIP(button,"reoptOld: Ch. 4.3 DEFAULT: FALSE\nIf set surviving structure will be re-optimized."); /* --- end frame */ +/* --- Structure & Variation */ + GUI_FRAME_NOTE(page,frame,"Structure & Variation"); +/* create a table in the frame*/ + GUI_TABLE_FRAME(frame,table,5,3); +/* 1st line */ + GUI_TEXT_TABLE(table,uspex_gui.symmetries,uspex_gui.calc.symmetries,"symmetries: ",0,2,0,1); +GUI_TOOLTIP(uspex_gui.symmetries,"symmetries: Ch. 4.4 DEFAULT: auto\nPossible space group for crystals,\nplane group for 2D crystals/surface\nor point group for clusters."); + GUI_ENTRY_TABLE(table,uspex_gui.fracGene,uspex_gui.calc.fracGene,"%.4f","fracGene:",2,3,0,1); +GUI_TOOLTIP(uspex_gui.fracGene,"fracGene: Ch. 4.4 DEFAULT: 0.5\nRatio of structures obtained by heredity."); + GUI_ENTRY_TABLE(table,uspex_gui.fracRand,uspex_gui.calc.fracRand,"%.4f","fracRand:",3,4,0,1); +GUI_TOOLTIP(uspex_gui.fracRand,"fracRand: Ch. 4.4 DEFAULT: 0.2\nRatio of structures obtained randomly."); + GUI_ENTRY_TABLE(table,uspex_gui.fracPerm,uspex_gui.calc.fracPerm,"%.4f","fracPerm:",4,5,0,1); +GUI_TOOLTIP(uspex_gui.fracPerm,"fracPerm: Ch. 4.4 DEFAULT: auto\nRatio of structures obtained by permutation."); +/* 2nd line */ + GUI_ENTRY_TABLE(table,uspex_gui.fracAtomsMut,uspex_gui.calc.fracAtomsMut,"%.4f","fracAtomsMut:",0,1,1,2); +GUI_TOOLTIP(uspex_gui.fracAtomsMut,"fracAtomsMut: Ch. 4.4 DEFAULT: 0.1\nRatio of structures obtained by softmutation."); + GUI_ENTRY_TABLE(table,uspex_gui.fracRotMut,uspex_gui.calc.fracRotMut,"%.4f","fracRotMut:",1,2,1,2); +GUI_TOOLTIP(uspex_gui.fracRotMut,"fracRotMut: Ch. 4.4 DEFAULT: auto\nRatio of structures obtained by mutation of molecular orientation."); + GUI_ENTRY_TABLE(table,uspex_gui.fracLatMut,uspex_gui.calc.fracLatMut,"%.4f","fracLatMut:",2,3,1,2); +GUI_TOOLTIP(uspex_gui.fracLatMut,"fracLatMut: Ch. 4.4 DEFAULT: auto\nRatio of structures obtained by lattice mutation."); + GUI_ENTRY_TABLE(table,uspex_gui.howManySwaps,uspex_gui.calc.howManySwaps,"%3i","N_SWAPS:",3,4,1,2); +GUI_TOOLTIP(uspex_gui.howManySwaps,"howManySwaps: Ch. 4.4 DEFAULT: auto\nNumber of pairwise swaps for permutation\ndistributed uniformly between [1,howManySwaps]."); + GUI_TEXT_TABLE(table,uspex_gui.specificSwaps,uspex_gui.calc.specificSwaps,"SWAPS: ",4,5,1,2); +GUI_TOOLTIP(uspex_gui.specificSwaps,"specificSwaps: Ch. 4.4 DEFAULT: blank\nWich atoms are allow to swap during permutation."); +/* 3rd line */ + GUI_ENTRY_TABLE(table,uspex_gui.mutationDegree,uspex_gui.calc.mutationDegree,"%.4f","mutationDegree:",0,1,2,3); +GUI_TOOLTIP(uspex_gui.mutationDegree,"mutationDegree: Ch. 4.4 DEFAULT: auto\nMaximum displacement in softmutation (Ang)."); + GUI_ENTRY_TABLE(table,uspex_gui.mutationRate,uspex_gui.calc.mutationRate,"%.4f","mutationRate:",1,2,2,3); +GUI_TOOLTIP(uspex_gui.mutationRate,"mutationRate: Ch. 4.4 DEFAULT: 0.5\nStd. dev. of epsilon in strain matrix for lattice mutation."); + GUI_ENTRY_TABLE(table,uspex_gui.DisplaceInLatmutation,uspex_gui.calc.DisplaceInLatmutation,"%.4f","D_LATMUT:",2,3,2,3); +GUI_TOOLTIP(uspex_gui.DisplaceInLatmutation,"DisplaceInLatmutation: Ch. 4.4 DEFAULT: 1.0\nSets softmutation as part of lattice mutation\nand gives maximum displacement (Ang)."); + GUI_CHECK_TABLE(table,uspex_gui.AutoFrac,uspex_gui.calc.AutoFrac,NULL,"AutoFrac",3,4,2,3);/*not calling anything*/ +GUI_TOOLTIP(uspex_gui.AutoFrac,"AutoFrac: Ch. 4.4 DEFAULT: FALSE\nIf set variation parameters will be optimized during run."); + GUI_CHECK_TABLE(table,button,uspex_gui.auto_SV,toggle_auto_SV,"AUTO_SV",4,5,2,3);/*TODO: autoSV*/ +GUI_TOOLTIP(button,"AUTO_SV: use automatic values for all Structure and Variation Parameters."); +/* initialize */ + toggle_auto_SV(); +/* --- end frame */ + + + + + + + + + + + + + diff --git a/src/gui_uspex.h b/src/gui_uspex.h index 0c2a33b..23a1a83 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -84,6 +84,21 @@ struct uspex_calc_gui{ GUI_OBJ *bestFrac; GUI_OBJ *keepBestHM; GUI_OBJ *reoptOld; +/*4.4 Structure generation and variation operators*/ + GUI_OBJ *symmetries; + GUI_OBJ *fracGene; + GUI_OBJ *fracRand; + GUI_OBJ *fracPerm; + GUI_OBJ *fracAtomsMut; + GUI_OBJ *fracRotMut; + GUI_OBJ *fracLatMut; + GUI_OBJ *howManySwaps; + GUI_OBJ *specificSwaps; + GUI_OBJ *mutationDegree; + GUI_OBJ *mutationRate; + GUI_OBJ *DisplaceInLatmutation; + GUI_OBJ *AutoFrac; + gboolean auto_SV; /* CALCUL */ GUI_OBJ *job_uspex_exe; From 174ac0b115e1fed56f0d343e56018408e6756b50 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Sat, 18 Aug 2018 14:54:22 +0900 Subject: [PATCH 29/56] gui_uspex: FIX a _BUG_ where uninitialized _num_opt_steps can cause giant memory allocation. --- src/file_uspex.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/file_uspex.c b/src/file_uspex.c index 78fa096..d073b93 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -110,6 +110,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.MolCenters=NULL; _UC.Latticevalues=NULL; _UC.splitInto=NULL; + _UC._num_opt_steps=0; _UC.abinitioCode=NULL; _UC.KresolStart=NULL; _UC.vacuumSize=NULL; @@ -181,6 +182,8 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ void free_uspex_parameters(uspex_calc_struct *uspex_calc){ /*free the sub-structures, and set it back to init*/ g_free(_UC.name); + g_free(_UC.path); + g_free(_UC.filename); g_free(_UC.atomType); g_free(_UC.numSpecies); g_free(_UC.valences); From b0733e53ef5abeb9e07bdec597367d76538ef041 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 20 Aug 2018 18:41:37 +0900 Subject: [PATCH 30/56] gui_uspex: gui_uspex V. --- src/file_uspex.c | 43 +++-- src/file_vasp.c | 2 +- src/gui_uspex.c | 480 ++++++++++++++++++++++++++++++++++++++++++++++- src/gui_uspex.h | 24 +++ 4 files changed, 523 insertions(+), 26 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index d073b93..f33b9c8 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -473,7 +473,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - if(g_ascii_isdigit(*ptr)) _UC.atomType[i]=g_ascii_strtod(ptr,NULL);/*user provided Z number*/ + if(g_ascii_isdigit(*ptr)) _UC.atomType[i]=(gint)g_ascii_strtod(ptr,NULL);/*user provided Z number*/ else _UC.atomType[i]=elem_symbol_test(ptr);/*try user provided symbol*/ if((_UC.atomType[i]<=0)||(_UC.atomType[i]>MAX_ELEMENTS-1)){/*invalid Z*/ _UC.atomType[i]=0;/*allow it for now*/ @@ -1031,6 +1031,7 @@ fprintf(stdout,"#DBG: PROBE FAIL LINE: %s",line); #undef __GET_CHARS } void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ +gint i; #define _SRC (*src) #define _DEST (*dest) #define _CP(value) _DEST.value=_SRC.value @@ -1043,6 +1044,15 @@ void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ _DEST.value=NULL;\ }\ }while(0) +#define _DBLCP(value,size) do{\ + if((_SRC.value)!=NULL){\ + if(_DEST.value!=NULL) g_free(_DEST.value);\ + _DEST.value = g_malloc(size*sizeof(gdouble));\ + for(i=0;i=uspex_gui.calc._nspecies){ + /*use only nspecies values*/ + ptr2=g_strdup_printf("%4f",distval[0]); + ptr=ptr2; + for(i=1;i=uspex_gui.calc._nmolecules){ + /*use only nmolecules values*/ + ptr2=g_strdup_printf("%4f",molval[0]); + ptr=ptr2; + for(i=1;i0){ + /*refresh MolCenters*/ + GUI_UNLOCK(uspex_gui.MolCenters); + GUI_UNLOCK(uspex_gui._centers); + /*wipe MolCenters, rewrite*/ + GUI_COMBOBOX_WIPE(uspex_gui.MolCenters); + for(i=0;i=6){/*drop every values over the 6th*/ + ptr=g_strdup_printf("%4f %4f %4f %4f %4f %4f",lval[0],lval[1],lval[2],lval[3],lval[4],lval[5]); + }else if(nlval==4){/*special definition*/ + ptr=g_strdup_printf("%4f %4f %4f %4f %4f %4f",lval[0],lval[1],0.,lval[2],lval[3],0.); + }else{/*zero padded*/ + ptr2=g_strdup_printf("%4f",lval[0]); + for(i=1;i1 is valid*/ + ptr2=g_strdup_printf("%4f",lval[0]); + ptr=ptr2; + for(i=1;i Date: Mon, 22 Oct 2018 20:16:49 +0900 Subject: [PATCH 31/56] file_uspex: update to USPEX version 10.1 (I) --- src/file_uspex.c | 395 ++++++++++++++++++++++++++--------------------- src/file_uspex.h | 89 ++++++++--- 2 files changed, 289 insertions(+), 195 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index f33b9c8..0224623 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -21,17 +21,17 @@ The GNU GPL can also be found at http://www.gnu.org */ /* USPEX Parser: - * The reading of USPEX result file is a little different: - * 1/ make a graph representing all structures energy levels vs. generation numbers - * -> make each point on that graph clickable so that selecting a point will - * open a new model containing the corresponding structure. - * 2/ load the optimal structures as base model. - * -> each optimal structure, for each generation, is represented as a frame - * in this model. - * TODO: - * 1/ include other data plots: - * - hardness / force vs. generation - * 2/ calculate some other properties... + * supported versions VER 10.1, VER 9.4.4 + * All structure geometries are displayed "as an animation", additionally + * also some graphs are produced depending on the USPEX calculation type: + * Graph ALL shows all structures energies vs generation number + * Graph BEST shows the best _fitness_ structures per generation + * Graph PATH shows the image energies of VCNEB/TPS optimization + * Graph COMP_X shows the structure energy for each X atomic ratio + * + * All graphs are selectable, ie. selecting a value represented by + * a square on a graph will load the structure on the main display + * * */ #include @@ -73,17 +73,28 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC._calctype_dim=3; _UC._calctype_mol=FALSE; _UC._calctype_var=FALSE; + _UC._calctype_mag=FALSE; //VER 10.1 _UC.optType=US_OT_ENTHALPY; + _UC.new_optType=NULL; //VER 10.1 _UC.anti_opt=FALSE; _UC._nspecies=0; _UC.atomType=NULL; _UC._var_nspecies=0; _UC.numSpecies=NULL; + _UC.magRatio[0]=0.1; //VER 10.1 + _UC.magRatio[1]=0.225; //VER 10.1 + _UC.magRatio[2]=0.225; //VER 10.1 + _UC.magRatio[3]=0.225; //VER 10.1 + _UC.magRatio[4]=0.225; //VER 10.1 + _UC.magRatio[5]=0.0; //VER 10.1 + _UC.magRatio[6]=0.0; //VER 10.1 + _UC.ldaU=NULL; //VER 10.1 _UC.ExternalPressure=0.; _UC.valences=NULL; _UC.goodBonds=NULL; _UC.checkMolecules=TRUE; _UC.checkConnectivity=FALSE; + _UC.fitLimit=0.; //VER 10.1 _UC.populationSize=0; _UC.initialPopSize=0; _UC.numGenerations=100; @@ -94,10 +105,12 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.symmetries=NULL; _UC.fracGene=0.5; _UC.fracRand=0.2; + _UC.fracTopRand=0.2; //VER 10.1 _UC.fracPerm=0.; _UC.fracAtomsMut=0.1; _UC.fracRotMut=0.; _UC.fracLatMut=0.; + _UC.fracSpinMut=0.1; //VER 10.1 _UC.howManySwaps=0; _UC.specificSwaps=NULL; _UC.mutationDegree=0; @@ -129,6 +142,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.SymTolerance=0.1; _UC.repeatForStatistics=1; _UC.stopFitness=0.; + _UC.fixRndSeed=0; //VER 10.1 _UC.collectForces=FALSE; _UC.ordering_active=TRUE; _UC.symmetrize=FALSE; @@ -141,6 +155,12 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.minSlice=0.; _UC.maxSlice=0.; _UC.numberparents=2; + _UC.BoltzTraP_T_max=800.0; //VER 10.1 + _UC.BoltzTraP_T_delta=50.0; //VER 10.1 + _UC.BoltzTraP_T_efcut=0.15; //VER 10.1 + _UC.TE_T_interest=300.0; //VER 10.1 + _UC.TE_threshold=0.5; //VER 10.1 + _UC.TE_goal=US_BT_ZT; //VER 10.1 _UC.thicknessS=2.0; _UC.thicknessB=3.0; _UC.reconstruct=1; @@ -178,14 +198,33 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.pickupImages=NULL; _UC.FormatType=2;/*MUST BE VASP FORMAT!*/ _UC.PrintStep=1; + _UC.numIterations=1000; //VER 10.1 + _UC.speciesSymbol=NULL; //VER 10.1 + _UC.mass=NULL; //VER 10.1 + _UC.amplitudeShoot[0]=0.1; //VER 10.1 + _UC.amplitudeShoot[1]=0.1; //VER 10.1 + _UC.magnitudeShoot[0]=1.05; //VER 10.1 + _UC.magnitudeShoot[1]=1.05; //VER 10.1 + _UC.shiftRatio=0.1; //VER 10.1 + _UC.orderParaType=TRUE; //VER 10.1 NOTE: here we select fingerprint method as default! + _UC.opCriteria[0]=0.; //VER 10.1 + _UC.opCriteria[1]=0.; //VER 10.1 + _UC.cmdOrderParameter=NULL; //VER 10.1 + _UC.cmdEnthalpyTemperature=NULL; //VER 10.1 + _UC.orderParameterFile=g_strdup("fp.dat"); //VER 10.1 + _UC.enthalpyTemperatureFile=g_strdup("HT.dat"); //VER 10.1 + _UC.trajectoryFile=g_strdup("traj.dat"); //VER 10.1 + _UC.MDrestartFile=g_strdup("traj.restart"); //VER 10.1 } void free_uspex_parameters(uspex_calc_struct *uspex_calc){ /*free the sub-structures, and set it back to init*/ g_free(_UC.name); g_free(_UC.path); g_free(_UC.filename); + g_free(_UC.new_optType); //VER 10.1 g_free(_UC.atomType); g_free(_UC.numSpecies); + g_free(_UC.ldaU); //VER 10.1 g_free(_UC.valences); g_free(_UC.goodBonds); g_free(_UC.symmetries); @@ -203,6 +242,14 @@ void free_uspex_parameters(uspex_calc_struct *uspex_calc){ g_free(_UC.softMutOnly); g_free(_UC.specificTrans); g_free(_UC.pickupImages); + g_free(_UC.speciesSymbol); //VER 10.1 + g_free(_UC.mass); //VER 10.1 + g_free(_UC.cmdOrderParameter); //VER 10.1 + g_free(_UC.cmdEnthalpyTemperature); //VER 10.1 + g_free(_UC.orderParameterFile); //VER 10.1 + g_free(_UC.enthalpyTemperatureFile); //VER 10.1 + g_free(_UC.trajectoryFile); //VER 10.1 + g_free(_UC.MDrestartFile); //VER 10.1 init_uspex_parameters(uspex_calc); } /************************************************************************/ @@ -223,8 +270,9 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ /**/ uspex_calc = g_malloc(sizeof(uspex_calc_struct)); init_uspex_parameters(uspex_calc); -/*some lazy defines*/ +/*this should be promoted*/ #define __Q(a) #a +/*some lazy defines*/ #define __GET_BOOL(value) if (find_in_string(__Q(value),line)!=NULL){\ k=0;sscanf(line,"%i%*s",&(k));\ _UC.value=(k==1);\ @@ -255,57 +303,42 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ g_free(ptr);g_free(line);line = file_read_line(vf);\ continue;\ } - +#define __COUNT_NUM(pointer,count) while(*pointer!='\0'){\ + while((!g_ascii_isdigit(*pointer))&&(*pointer!='\0')) pointer++;\ + if(g_ascii_isdigit(*pointer)) count++;\ + while(g_ascii_isgraph(*pointer)&&(*pointer!='\0')) pointer++;\ +} +#define __COUNT_ALNUM(pointer,count) while(*pointer!='\0'){\ + while((!g_ascii_isalnum(*pointer))&&(*pointer!='\0')) pointer++;\ + if(g_ascii_isalnum(*pointer)) count++;\ + while(g_ascii_isgraph(*pointer)&&(*pointer!='\0')) pointer++;\ +} line = file_read_line(vf); /* +++ 1st PASS: get important numbers*/ while(line){ if (find_in_string("atomType",line) !=NULL){ g_free(line);line = file_read_line(vf);/*go next line*/ ptr=&(line[0]); - while(*ptr==' ') ptr++; - _UC._nspecies=1; - while(*ptr!='\0'){ - if(*ptr==' ') { - _UC._nspecies++;ptr++; - while(g_ascii_isgraph(*ptr)) ptr++; - }else ptr++; - } + /*NEW: more safe*/ + _UC._nspecies=1;__COUNT_ALNUM(ptr,_UC._nspecies); g_free(line);line = file_read_line(vf);/*this is the EndAtomType line*/ g_free(line);line = file_read_line(vf); continue; } -if((find_in_string("abinitioCode",line)!=NULL)||(find_in_string("KresolStart",line)!=NULL)||(find_in_string("vacuumSize",line)!=NULL)){ - /*FIXME: there seems to be no way to get the number of optimization step (_num_opt_steps): - * abinitioCode -> can be only one value - * KresolStart -> can be omitted - * vacuumSize -> can be less than _num_opt_steps, also can be omitted - * commandExecutable -> can be less than _num_opt_steps */ + if(find_in_string("abinitioCode",line)!=NULL){ + /*FIXME: in order to determine _num_opt_steps, * + * the number of items in abinitioCode is read * + * Even though 1 or VASP is stated as default. * + * ie. abinitioCode CANNOT be omited. --ovhpa */ g_free(line);line = file_read_line(vf); ptr=&(line[0]); - while(*ptr==' ') ptr++; - i=1; - while(*ptr!='\0'){ - if(*ptr==' ') { - i++;ptr++; - while(g_ascii_isgraph(*ptr)) ptr++; - }else ptr++; - } + /*NEW: more safe*/ + i=0;__COUNT_NUM(ptr,i); if(i>_UC._num_opt_steps) _UC._num_opt_steps=i; g_free(line);line = file_read_line(vf); g_free(line);line = file_read_line(vf); continue; } - if(find_in_string("commandExecutable",line) != NULL){ - /*count the number of lines before EndExecutable, and hope it does represent _num_opt_steps*/ - i=0; - while(find_in_string("EndExecutable",line) == NULL){ - i++; - g_free(line);line = file_read_line(vf); - } - if(i>_UC._num_opt_steps) _UC._num_opt_steps=i; - g_free(line);line = file_read_line(vf); - continue; - } /*no catch*/ g_free(line);line = file_read_line(vf); } @@ -323,14 +356,16 @@ if((find_in_string("abinitioCode",line)!=NULL)||(find_in_string("KresolStart",li } } rewind(vf); -/* +++ 2nd PASS: get everything*/ +/* +++ 2nd PASS: get everything else*/ line = file_read_line(vf); while(line){ #if DEBUG_USPEX_READ fprintf(stdout,"#DBG: PROBE LINE: %s",line); #endif if (find_in_string("calculationMethod",line) != NULL) { - c='\0';sscanf(line,"%c%*s",&(c)); + ptr=&(line[0]); + while(g_ascii_isgraph(*ptr)) ptr++;/*skip blank*/ + c=*ptr;//sscanf(line,"%c%*s",&(c)); switch(c){ case 'u': case 'U':/*USPEX method*/ @@ -338,17 +373,24 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); break; case 'm': case 'M': - _UC.calculationMethod=US_CM_META; - break; + /*MINHOP is unsupported*/ + ptr++;if((*ptr=='i')||(*ptr=='I')) _UC.calculationMethod=US_CM_UNKNOWN; + else _UC.calculationMethod=US_CM_META; + break; //VER 10.1 case 'v': case 'V': _UC.calculationMethod=US_CM_VCNEB; break; case 'p': case 'P': - /*PSO method is not supported yet*/ _UC.calculationMethod=US_CM_PSO; break; + case 'T': + case 't': + _UC.calculationMethod=US_CM_TPS; + break; //VER 10.1 + case 'C': + case 'c'://COPEX is unsupported VER 10.1 default: _UC.calculationMethod=US_CM_UNKNOWN; } @@ -357,6 +399,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); continue; } if (find_in_string("calculationType",line) != NULL) { + /*VER 10.1 TODO check for 's' initial character*/ k=0;sscanf(line,"%i%*s",&(k)); j=k; i=((int)(j/100))%10; @@ -1031,7 +1074,7 @@ fprintf(stdout,"#DBG: PROBE FAIL LINE: %s",line); #undef __GET_CHARS } void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ -gint i; + gint i; #define _SRC (*src) #define _DEST (*dest) #define _CP(value) _DEST.value=_SRC.value @@ -1061,130 +1104,130 @@ gint i; _DEST.value=NULL;\ }\ }while(0) -/*1st free / init the destination*/ -free_uspex_parameters(dest); -init_uspex_parameters(dest); -/*copy*/ -_CP(name); -_STRCP(filename); -_STRCP(path); -_CP(special); -_CP(calculationMethod); -_CP(calculationType); -_CP(_calctype_dim); -_CP(_calctype_mol); -_CP(_calctype_var); -_CP(optType); -_CP(anti_opt); -_CP(_nspecies); -_COPY(atomType,_SRC._nspecies,gint); -_CP(_var_nspecies); -_COPY(numSpecies,(_SRC._nspecies*_SRC._var_nspecies),gint); -_CP(ExternalPressure); -_COPY(valences,_SRC._nspecies,gint); -_DBLCP(goodBonds,_SRC._nspecies*_SRC._nspecies); -_CP(checkMolecules); -_CP(checkConnectivity); -_CP(populationSize); -_CP(initialPopSize); -_CP(numGenerations); -_CP(stopCrit); -_CP(bestFrac); -_CP(keepBestHM); -_CP(reoptOld); -_STRCP(symmetries); -_CP(fracGene); -_CP(fracRand); -_CP(fracPerm); -_CP(fracAtomsMut); -_CP(fracRotMut); -_CP(fracLatMut); -_CP(howManySwaps); -_STRCP(specificSwaps); -_CP(mutationDegree); -_CP(mutationRate); -_CP(DisplaceInLatmutation); -_CP(AutoFrac); -_CP(minVectorLength); -_DBLCP(IonDistances,_SRC._nspecies*_SRC._nspecies); -_CP(constraint_enhancement); -_CP(_nmolecules); -_DBLCP(MolCenters,_SRC._nmolecules); -if(_SRC._calctype_var){ - _DBLCP(Latticevalues,_SRC._nlatticevalues); -}else{ - if(_SRC._nlatticevalues==6) _DBLCP(Latticevalues,6); - else if(_SRC._nlatticevalues<=3) _DBLCP(Latticevalues,_SRC._nlatticevalues*_SRC._nlatticevalues); - else if(_SRC._nlatticevalues==1) _DBLCP(Latticevalues,1); -} -_COPY(splitInto,_SRC._nsplits,gint); -_COPY(abinitioCode,_SRC._num_opt_steps,gint); -_DBLCP(KresolStart,_SRC._num_opt_steps); -_DBLCP(vacuumSize,_SRC._num_opt_steps); -_CP(numParallelCalcs); -_STRCP(commandExecutable);/*unsure*/ -_CP(whichCluster); -_STRCP(remoteFolder); -_CP(PhaseDiagram); -_CP(RmaxFing); -_CP(deltaFing); -_CP(sigmaFing); -_CP(antiSeedsActivation); -_CP(antiSeedsMax); -_CP(antiSeedsSigma); -_CP(doSpaceGroup); -_CP(SymTolerance); -_CP(repeatForStatistics); -_CP(stopFitness); -_CP(collectForces); -_CP(ordering_active); -_CP(symmetrize); -_COPY(valenceElectr,_SRC._nspecies,gint); -_CP(percSliceShift); -_CP(dynamicalBestHM); -_STRCP(softMutOnly); -_CP(maxDistHeredity); -_CP(manyParents); -_CP(minSlice); -_CP(maxSlice); -_CP(numberparents); -_CP(thicknessS); -_CP(thicknessB); -_CP(reconstruct); -_CP(firstGeneMax); -_CP(minAt); -_CP(maxAt); -_CP(fracTrans); -_CP(howManyTrans); -_COPY(specificTrans,_SRC._nspetrans,gint); -_CP(GaussianWidth); -_CP(GaussianHeight); -_CP(FullRelax); -_CP(maxVectorLength); -_CP(PSO_softMut); -_CP(PSO_BestStruc); -_CP(PSO_BestEver); -_CP(vcnebType); -_CP(_vcnebtype_method); -_CP(_vcnebtype_img_num); -_CP(_vcnebtype_spring); -_CP(numImages); -_CP(numSteps); -_CP(optReadImages); -_CP(optimizerType); -_CP(optRelaxType); -_CP(dt); -_CP(ConvThreshold); -_CP(VarPathLength); -_CP(K_min); -_CP(K_max); -_CP(Kconstant); -_CP(optFreezing); -_CP(optMethodCIDI); -_CP(startCIDIStep); -_COPY(pickupImages,_SRC._npickimg,gint); -_CP(FormatType); -_CP(PrintStep); + /*1st free / init the destination*/ + free_uspex_parameters(dest); + init_uspex_parameters(dest); + /*copy*/ + _CP(name); + _STRCP(filename); + _STRCP(path); + _CP(special); + _CP(calculationMethod); + _CP(calculationType); + _CP(_calctype_dim); + _CP(_calctype_mol); + _CP(_calctype_var); + _CP(optType); + _CP(anti_opt); + _CP(_nspecies); + _COPY(atomType,_SRC._nspecies,gint); + _CP(_var_nspecies); + _COPY(numSpecies,(_SRC._nspecies*_SRC._var_nspecies),gint); + _CP(ExternalPressure); + _COPY(valences,_SRC._nspecies,gint); + _DBLCP(goodBonds,_SRC._nspecies*_SRC._nspecies); + _CP(checkMolecules); + _CP(checkConnectivity); + _CP(populationSize); + _CP(initialPopSize); + _CP(numGenerations); + _CP(stopCrit); + _CP(bestFrac); + _CP(keepBestHM); + _CP(reoptOld); + _STRCP(symmetries); + _CP(fracGene); + _CP(fracRand); + _CP(fracPerm); + _CP(fracAtomsMut); + _CP(fracRotMut); + _CP(fracLatMut); + _CP(howManySwaps); + _STRCP(specificSwaps); + _CP(mutationDegree); + _CP(mutationRate); + _CP(DisplaceInLatmutation); + _CP(AutoFrac); + _CP(minVectorLength); + _DBLCP(IonDistances,_SRC._nspecies*_SRC._nspecies); + _CP(constraint_enhancement); + _CP(_nmolecules); + _DBLCP(MolCenters,_SRC._nmolecules); + if(_SRC._calctype_var){ + _DBLCP(Latticevalues,_SRC._nlatticevalues); + }else{ + if(_SRC._nlatticevalues==6) _DBLCP(Latticevalues,6); + else if(_SRC._nlatticevalues<=3) _DBLCP(Latticevalues,_SRC._nlatticevalues*_SRC._nlatticevalues); + else if(_SRC._nlatticevalues==1) _DBLCP(Latticevalues,1); + } + _COPY(splitInto,_SRC._nsplits,gint); + _COPY(abinitioCode,_SRC._num_opt_steps,gint); + _DBLCP(KresolStart,_SRC._num_opt_steps); + _DBLCP(vacuumSize,_SRC._num_opt_steps); + _CP(numParallelCalcs); + _STRCP(commandExecutable);/*unsure*/ + _CP(whichCluster); + _STRCP(remoteFolder); + _CP(PhaseDiagram); + _CP(RmaxFing); + _CP(deltaFing); + _CP(sigmaFing); + _CP(antiSeedsActivation); + _CP(antiSeedsMax); + _CP(antiSeedsSigma); + _CP(doSpaceGroup); + _CP(SymTolerance); + _CP(repeatForStatistics); + _CP(stopFitness); + _CP(collectForces); + _CP(ordering_active); + _CP(symmetrize); + _COPY(valenceElectr,_SRC._nspecies,gint); + _CP(percSliceShift); + _CP(dynamicalBestHM); + _STRCP(softMutOnly); + _CP(maxDistHeredity); + _CP(manyParents); + _CP(minSlice); + _CP(maxSlice); + _CP(numberparents); + _CP(thicknessS); + _CP(thicknessB); + _CP(reconstruct); + _CP(firstGeneMax); + _CP(minAt); + _CP(maxAt); + _CP(fracTrans); + _CP(howManyTrans); + _COPY(specificTrans,_SRC._nspetrans,gint); + _CP(GaussianWidth); + _CP(GaussianHeight); + _CP(FullRelax); + _CP(maxVectorLength); + _CP(PSO_softMut); + _CP(PSO_BestStruc); + _CP(PSO_BestEver); + _CP(vcnebType); + _CP(_vcnebtype_method); + _CP(_vcnebtype_img_num); + _CP(_vcnebtype_spring); + _CP(numImages); + _CP(numSteps); + _CP(optReadImages); + _CP(optimizerType); + _CP(optRelaxType); + _CP(dt); + _CP(ConvThreshold); + _CP(VarPathLength); + _CP(K_min); + _CP(K_max); + _CP(Kconstant); + _CP(optFreezing); + _CP(optMethodCIDI); + _CP(startCIDIStep); + _COPY(pickupImages,_SRC._npickimg,gint); + _CP(FormatType); + _CP(PrintStep); } /*****************************************/ diff --git a/src/file_uspex.h b/src/file_uspex.h index 25fcd9e..5b0013c 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -31,19 +31,28 @@ typedef enum {/*released USPEX calculation methods as of 2018 (5)*/ US_CM_USPEX, /*USPEX*/ US_CM_META, /*metadynamics*/ US_CM_VCNEB, /*VC-NEB*/ - US_CM_PSO, /*PSO, unsupported*/ - US_CM_UNKNOWN, /*reserved for future use*/ + US_CM_PSO, /*PSO*/ + US_CM_TPS, /*TPS VER 10.1*/ + US_CM_MINHOP, /*MINHOP, unsupported VER 10.1*/ + US_CM_COPEX, /*COPEX, unsupported VER 10.1*/ + US_CM_UNKNOWN, /*unknown*/ } uspex_method; typedef enum{ US_CT_300=300, /*bulk crystals; no-mol; no-var*/ + US_CT_s300=1300, /*+magnetic VER 10.1*/ US_CT_301=301, /*bulk crystals; no-mol; var*/ + US_CT_s301=1301, /*+magnetic VER 10.1*/ US_CT_310=310, /*bulk crystals; mol; no-var*/ US_CT_311=311, /*bulk crystals; mol; var*/ US_CT_000=0, /*nanoparticles; no-mol; no-var*/ + US_CT_s000=1000, /*+magnetic VER 10.1*/ US_CT_110=110, /*polymers; no-mol; no-var*/ US_CT_200=200, /*surfaces; no-mol; no-var*/ + US_CT_s200=1200, /*+magnetic VER 10.1*/ US_CT_201=201, /*surfaces; no-mol; var*/ - US_CT_M200=-200, /*2D crystals; no-mol; no-var*/ + US_CT_s201=1201, /*+magnetic VER 10.1*/ + US_CT_m200=-200, /*2D crystals; no-mol; no-var*/ + US_CT_sm200=-1200, /*+magnetic VER 10.1*/ } uspex_type; typedef enum { US_OT_ENTHALPY=1, /*most stable structure*/ @@ -56,6 +65,9 @@ typedef enum { US_OT_DIELEC_GAP=8, /*max energy storage capacity*/ US_OT_MAG=9, /*max magnetization*/ US_OT_QE=10, /*max stucture quasientropy*/ + US_OT_2R=11, /*birefringence VER 10.1*/ + US_OT_ZT=14, /*thermoelectric VER 10.1*/ + US_OT_Fphon=17, /*free energy & finite temperature VER 10.1*/ /*elasticity related*/ US_OT_BULK_M=1101, /*max bulk modulus*/ US_OT_SHEAR_M=1102, /*max shear modulus*/ @@ -70,6 +82,12 @@ typedef enum { US_OT_PWAVE_V=1111, /*max P-wave velocity*/ US_OT_UNKNOWN=0, /*reserved for future use*/ } uspex_opt; +typedef enum { + US_BT_ZT=0, /*trace of BT figure of merit (ZT)*/ + US_BT_ZTxx=0, /*x diagonal component of ZT*/ + US_BT_ZTyy=0, /*y diagonal component of ZT*/ + US_BT_ZTzz=0, /*z diagonal component of ZT*/ +} uspex_bt_goal; typedef struct { gint gen; /*generation of this individual*/ gint natoms; /*number of atoms*/ @@ -89,20 +107,26 @@ typedef struct { /*4.1 Type of run & System*/ uspex_method calculationMethod; /*supported calculation methods*/ uspex_type calculationType; /*supported calculation types*/ - gint _calctype_dim; /*HIDDEN: X.. digit in calculation type: dimension*/ - gboolean _calctype_mol; /*HIDDEN: .X. digit in calculation type: molecular*/ - gboolean _calctype_var; /*HIDDEN: ..X digit in calculation type: variable composition*/ + gint _calctype_dim; /*HIDDEN: X.. digit in calculation type: dimension*/ + gboolean _calctype_mol; /*HIDDEN: .X. digit in calculation type: molecular*/ + gboolean _calctype_var; /*HIDDEN: ..X digit in calculation type: variable composition*/ + gboolean _calctype_mag; /*HIDDEN: s... trigger magnetic calculation VER 10.1*/ uspex_opt optType; /*optimization property*/ + gchar *new_optType; /*extended property of optimization VER 10.1*/ gboolean anti_opt; /*if set, reverse the optimization direction*/ gint _nspecies; /*HIDDEN: number of different species*/ gint *atomType; /*atomic number of each species*/ gint _var_nspecies; /*HIDDEN: numer of numSpecies blocks*/ gint *numSpecies; /*number of species for each type*/ + gdouble magRatio[7]; /*fraction of initial structures with: + NM, FM-LS, FM-HS, AFM-L, AFM-H, FM-LH, AF-LH VER 10.1*/ + gdouble *ldaU; /*U value for VASP LDA+U {in Dudarev et al. formalism} VER 10.1*/ gdouble ExternalPressure; /*external pressure*/ gint *valences; /*valence for each species*/ gdouble *goodBonds; /*minimum bond valences*/ gboolean checkMolecules; /*check molecules*/ gboolean checkConnectivity; /*check connectivity*/ + gdouble fitLimit; /*best fitness stop criterion VER 10.1*/ /*4.2 Population*/ gint populationSize; /*number of structure in each generation*/ gint initialPopSize; /*number of structure in initial generation*/ @@ -116,10 +140,12 @@ typedef struct { gchar *symmetries; /*possible symmetries*/ gdouble fracGene; /*fraction of structures generated by heredity*/ gdouble fracRand; /*fraction of structures generated randomly*/ + gdouble fracTopRand; /*fraction of structures generated by topological randomness VER 10.1*/ gdouble fracPerm; /*fraction of structures generated by permutation*/ gdouble fracAtomsMut; /*fraction of structures generated by softmutation*/ gdouble fracRotMut; /*fraction of structures generated by orientation mutation*/ gdouble fracLatMut; /*fraction of structures generated by lattice mutation*/ + gdouble fracSpinMut; /*fraction of structures generated by spin mutation VER 10.1*/ gint howManySwaps; /*number of pairwise swaps*/ gchar *specificSwaps; /*which atoms are swapped*/ gdouble mutationDegree; /*max displacement (Ang) in softmutation*/ @@ -163,6 +189,7 @@ typedef struct { /*4.12 Developers*/ gint repeatForStatistics; /*repeat USPEX calculation rFS times*/ gdouble stopFitness; /*set halting fitness condition*/ + gint fixRndSeed; /*fixed random seed number VER 10.1*/ gboolean collectForces; /*collect all relaxation information (from VASP)*/ /*4.13 Seldom*/ gboolean ordering_active; /*biasing of variation parameters*/ @@ -179,11 +206,20 @@ typedef struct { /*5 Additional*/ /*5.1 molecular crystal*/ /*no keyword in this section*/ -/*5.2 Surfaces*/ +/*VER 10.1 - 5.2 Optimization of thermoelectric efficiency (new)*/ + gdouble BoltzTraP_T_max; /*Max temperature in K VER 10.1*/ + gdouble BoltzTraP_T_delta; /*Temperature increment in K VER 10.1*/ + gdouble BoltzTraP_T_efcut; /*Chemical potential interval in eV VER 10.1*/ + gdouble TE_T_interest; /*Target temperature in K VER 10.1*/ + gdouble TE_threshold; /*discard structures with a lower ZT - figure of merit VER 10.1*/ + uspex_bt_goal TE_goal; /*component of ZT to be optimized VER 10.1*/ +/*5.3 Surfaces (previously 5.2)*/ gdouble thicknessS; /*thickness (Ang) of the surface (ie adatoms) surface region*/ gdouble thicknessB; /*thickness (Ang) of the buffer (no adatoms) surface region*/ gint reconstruct; /*max number of multiplication of the surface cell (for reconstruction)*/ -/*5.3 Variable composition*/ +/*VER 10.1 - 5.4 Clusters*/ + /*no keyword in this section (selection by calculationType)*/ +/*5.5 Variable composition (previously 5.3)*/ gint firstGeneMax; /*how many different composition are sampled in the 1st generation*/ gint minAt; /*minimum number of atoms/unit cell in the 1st generation*/ gint maxAt; /*maximum number of atoms/unit cell in the 1st generation*/ @@ -191,25 +227,25 @@ typedef struct { gdouble howManyTrans; /*maximum fraction of atoms in the structure that are being transmuted*/ gint _nspetrans; /*HIDDEN: number of specific transmutations*/ gint *specificTrans; /*specific transmutations*/ -/*5.4 metadynamics*/ +/*5.6 metadynamics (previously 5.4)*/ gdouble GaussianWidth; /*width of each gaussian added to surface energy*/ gdouble GaussianHeight; /*height of each gaussian added to surface energy*/ gint FullRelax; /*whether relax within a fixed cell, fully relax best, or all structures*/ gdouble maxVectorLength; /*maximum (Ang) unit cell length (if larger then steep force correction is added)*/ -/*5.5 Particle swarm optimization*/ +/*5.7 Particle swarm optimization (previously 5.5)*/ gdouble PSO_softMut; /*weight of softmutation*/ gdouble PSO_BestStruc; /*weight of heredity with best position, within same PSO particle*/ gdouble PSO_BestEver; /*weight of heredity with globally best PSO particle*/ /*6 Phase Transition Pathways*/ -/*6.1 VC-NEB*/ +/*6.1 Variable cell nudged elastic band (VCNEB)*/ /*no keyword in this section*/ -/*6.2 VC-NEB options*/ - gint vcnebType; /*type of VC-NEB*/ +/*6.1.1 VCNEB options (previously 6.2)*/ + gint vcnebType; /*type of VCNEB*/ gint _vcnebtype_method; /*HIDDEN: X.. digit in vcnebType: use VCNEB or just relax*/ gboolean _vcnebtype_img_num; /*HIDDEN: .X. digit in vcnebType: fixed or variable image number*/ gboolean _vcnebtype_spring; /*HIDDEN: ..X digit in vcnebType: fixed or variable spring constant*/ gint numImages; /*initial number of images*/ - gint numSteps; /*maximum VC-NEB steps*/ + gint numSteps; /*maximum VCNEB steps*/ gint optReadImages; /*reading the Image file (all image, initial and final, or +intermediate)*/ gint optimizerType; /*optimization algorithm*/ gint optRelaxType; /*relaxation mode (fixed cell, only cell, full relaxation)*/ @@ -225,12 +261,27 @@ typedef struct { gint _npickimg; /*HIDDEN: number of picked-up images*/ gint *pickupImages; /*# of images chosen for CI/DI*/ gint FormatType; /*structure format in the output pathway (ONLY VASP5 is supported!)*/ - gint PrintStep; /*save VC-NEB restart files in STEP directory every PS steps*/ -/*6.3 Set initial pathway in VC-NEB*/ + gint PrintStep; /*save VCNEB restart files in STEP directory every PS steps*/ +/*6.1.2 Set initial pathway in VCNEB (perviously 6.3)*/ /*no keyword in this section*/ - - - +/*VER 10.1 - 6.2 Transistion path sampling (TPS)*/ + /*no keyword in this section*/ +/*vER 10.1 - 6.2.1 TPS options*/ + gint numIterations; /*max number of TPS steps VER 10.1*/ + gchar *speciesSymbol; /*Symbols for all atoms or molecules VER 10.1*/ + gdouble *mass; /*mass of each species VER 10.1*/ + gdouble amplitudeShoot[2]; /*momentum amplitude for A->B and B->A VER 10.1*/ + gdouble magnitudeShoot[2]; /*succeed and fail factors for: + increasing/decreasing amplitude of magnitude distribution VER 10.1*/ + gdouble shiftRatio; /*ratio for a shifter op after a successful shooter one VER 10.1*/ + gboolean orderParaType; /*method of order parameter: FALSE -> custom ; TRUE -> fingerprint VER 10.1*/ + gdouble opCriteria[2]; /*tolerable similarity of starting and ending state VER 10.1*/ + gchar *cmdOrderParameter; /*custom command for orderParaType=FALSE*/ + gchar *cmdEnthalpyTemperature; /*custom command to extract enthalpy and temperature from MD VER 10.1*/ + gchar *orderParameterFile; /*filename to store order VER 10.1*/ + gchar *enthalpyTemperatureFile; /*filename to store enthalpy and temperature VER 10.1*/ + gchar *trajectoryFile; /*filename to store the MD trajectory VER 10.1*/ + gchar *MDrestartFile; /*filename to store the MD restart file VER 10.1*/ /*run parameters*/ gchar *job_uspex_exe; gchar *job_path; From 717660900aa13fd040c9187726fb04d0615d62e8 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Tue, 23 Oct 2018 18:00:47 +0900 Subject: [PATCH 32/56] file_uspex: update to USPEX version 10.1 (II) --- src/file_uspex.c | 460 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 317 insertions(+), 143 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 0224623..bc33d67 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -259,7 +259,7 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ FILE *vf; long int vfpos; gchar *line=NULL; - gchar *ptr; + gchar *ptr,*ptr2; gchar c; gint i,j,k; uspex_calc_struct *uspex_calc; @@ -313,6 +313,7 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ if(g_ascii_isalnum(*pointer)) count++;\ while(g_ascii_isgraph(*pointer)&&(*pointer!='\0')) pointer++;\ } +#define __SKIP_BLANK(pointer) while(!g_ascii_isgraph(*pointer)&&(*ptr!='\0')) ptr++ line = file_read_line(vf); /* +++ 1st PASS: get important numbers*/ while(line){ @@ -320,7 +321,8 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ g_free(line);line = file_read_line(vf);/*go next line*/ ptr=&(line[0]); /*NEW: more safe*/ - _UC._nspecies=1;__COUNT_ALNUM(ptr,_UC._nspecies); + _UC._nspecies=0;__COUNT_ALNUM(ptr,_UC._nspecies); + if(_UC._nspecies<1) _UC._nspecies=1;/*there is at least 1 species*/ g_free(line);line = file_read_line(vf);/*this is the EndAtomType line*/ g_free(line);line = file_read_line(vf); continue; @@ -335,7 +337,7 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ /*NEW: more safe*/ i=0;__COUNT_NUM(ptr,i); if(i>_UC._num_opt_steps) _UC._num_opt_steps=i; - g_free(line);line = file_read_line(vf); + g_free(line);line = file_read_line(vf);/*this is the ENDabinit line*/ g_free(line);line = file_read_line(vf); continue; } @@ -364,7 +366,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); #endif if (find_in_string("calculationMethod",line) != NULL) { ptr=&(line[0]); - while(g_ascii_isgraph(*ptr)) ptr++;/*skip blank*/ + __SKIP_BLANK(ptr); c=*ptr;//sscanf(line,"%c%*s",&(c)); switch(c){ case 'u': @@ -399,110 +401,232 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); continue; } if (find_in_string("calculationType",line) != NULL) { - /*VER 10.1 TODO check for 's' initial character*/ - k=0;sscanf(line,"%i%*s",&(k)); - j=k; - i=((int)(j/100))%10; + ptr=&(line[0]); + _UC.calculationType=0; + __SKIP_BLANK(ptr); + if(*ptr=='-') {/*2D-crystal*/ + j=-1; + ptr++; + }else j=1; + if((*ptr=='s')||(*ptr=='S')) {/*VER 10.1: magnetic*/ + _UC._calctype_mag=TRUE; + _UC.calculationType=1000; + ptr++; + } + i=g_ascii_digit_value(*ptr);/*dimension*/ if((i!=-2)&&((i<0)||(i>3))) { g_free(line); line = file_read_line(vf); continue; } _UC._calctype_dim=i; - j-=i*100; - if(j<0) j*=-1; - i=((int)(j/10))%10; + ptr++; + i=g_ascii_digit_value(*ptr);/*molecular*/ if((i<0)||(i>1)){ g_free(line); line = file_read_line(vf); continue; } _UC._calctype_mol=(i==1); - j-=i*10; - i=j%10; + ptr++; + i=g_ascii_digit_value(*ptr);/*variable*/ if((i<0)||(i>1)){ g_free(line); line = file_read_line(vf); continue; } _UC._calctype_var=(i==1); - _UC.calculationType=k; + _UC.calculationType+=(_UC._calctype_dim*100)+(_UC._calctype_mol*10)+_UC._calctype_var; + _UC.calculationType*=j; g_free(line); line = file_read_line(vf); continue; } if (find_in_string("optType",line) != NULL) { - k=0;sscanf(line,"%i%*s",&(k)); - if(k<0) { - _UC.anti_opt=TRUE; - k*=-1; - } - switch (k){ - case 1: - _UC.optType=US_OT_ENTHALPY; - break; - case 2: - _UC.optType=US_OT_VOLUME; - break; - case 3: - _UC.optType=US_OT_HARDNESS; - break; - case 4: - _UC.optType=US_OT_ORDER; - break; - case 5: - _UC.optType=US_OT_DISTANCE; - break; - case 6: - _UC.optType=US_OT_DIELEC_S; - break; - case 7: - _UC.optType=US_OT_GAP; - break; - case 8: - _UC.optType=US_OT_DIELEC_GAP; - break; - case 9: - _UC.optType=US_OT_MAG; - break; - case 10: - _UC.optType=US_OT_QE; - break; - case 1101: - _UC.optType=US_OT_BULK_M; - break; - case 1102: - _UC.optType=US_OT_SHEAR_M; - break; - case 1103: - _UC.optType=US_OT_YOUNG_M; - break; - case 1104: - _UC.optType=US_OT_POISSON; - break; - case 1105: - _UC.optType=US_OT_PUGH_R; - break; - case 1106: - _UC.optType=US_OT_VICKERS_H; - break; - case 1107: - _UC.optType=US_OT_FRACTURE; - break; - case 1108: - _UC.optType=US_OT_DEBYE_T; - break; - case 1109: - _UC.optType=US_OT_SOUND_V; - break; - case 1110: - _UC.optType=US_OT_SWAVE_V; - break; - case 1111: - _UC.optType=US_OT_PWAVE_V; - break; - default: - _UC.optType=US_OT_UNKNOWN; + /*VER 10.1 has a new format !*/ + ptr=&(line[0]); + __SKIP_BLANK(ptr); + if(g_ascii_isalpha(*ptr)){ + if((*ptr=='m')||(*ptr=='M')){ + /*could be Min max*/ + j=0; + if((*(ptr+1)=='a')&&(*(ptr+2)=='x')) { + /*can be mag_moment -> checked x*/ + j=1; + ptr+=4; + } + if(*(ptr+1)=='i') { + /*can be only Min*/ + j=-1; + ptr+=4; + } + } + c=*ptr; + switch(c){ + case 'E': + case 'e': + _UC.optType=US_OT_ENTHALPY; + if(j==1) _UC.anti_opt=TRUE; + break; + case 'v': + case 'V': + _UC.optType=US_OT_VOLUME; + if(j==1) _UC.anti_opt=TRUE; + break; + case 'h': + case 'H': + _UC.optType=US_OT_HARDNESS; + if(j==-1) _UC.anti_opt=TRUE; + break; + case 's': + case 'S': + _UC.optType=US_OT_ORDER; + if(j==-1) _UC.anti_opt=TRUE; + break; + case 'a': + case 'A': + _UC.optType=US_OT_DISTANCE; + if(j==-1) _UC.anti_opt=TRUE; + break; + case 'd': + case 'D': + if((*(ptr+1)=='e')||(*(ptr+1)=='E')){ + /*VER 10.1 "density" replaces "aver_dist"*/ + _UC.optType=US_OT_DISTANCE; + if(j==-1) _UC.anti_opt=TRUE; + break; + }else if((*(ptr+1)=='i')||(*(ptr+1)=='I')){ + if((*(ptr+5)=='s')||(*(ptr+5)=='S')) _UC.optType=US_OT_DIELEC_S; + else if((*(ptr+5)=='g')||(*(ptr+5)=='G')) _UC.optType=US_OT_DIELEC_GAP; + else _UC.optType=US_OT_UNKNOWN; + if(j==-1) _UC.anti_opt=TRUE; + } else _UC.optType=US_OT_UNKNOWN; + break; + case 'g': + case 'G': + _UC.optType=US_OT_GAP; + break; + case 'b': + case 'B': + if((*(ptr+1)=='a')||(*(ptr+1)=='A')){ + /*VER 10.1 "bandgap" replaces "gap"*/ + _UC.optType=US_OT_GAP; + break; + } else if((*(ptr+1)=='i')||(*(ptr+1)=='I')){ + _UC.optType=US_OT_2R;/*VER 10.1*/ + break; + } + case 'm': + case 'M': + _UC.optType=US_OT_MAG; + break; + case 'q': + case 'Q': + _UC.optType=US_OT_QE; + break; + case 'z': + case 'Z': + _UC.optType=US_OT_ZT; + break; + case 'f': + case 'F': + _UC.optType=US_OT_Fphon; + break; + default: + _UC.optType=US_OT_UNKNOWN; + } + } else if(g_ascii_isdigit(*ptr)||(*ptr=='-')){ + /*load optType*/ + k=0;sscanf(ptr,"%i%*s",&(k)); + if(k<0) { + _UC.anti_opt=TRUE; + k*=-1; + } + switch (k){ + case 1: + _UC.optType=US_OT_ENTHALPY; + break; + case 2: + _UC.optType=US_OT_VOLUME; + break; + case 3: + _UC.optType=US_OT_HARDNESS; + break; + case 4: + _UC.optType=US_OT_ORDER; + break; + case 5: + _UC.optType=US_OT_DISTANCE; + break; + case 6: + _UC.optType=US_OT_DIELEC_S; + break; + case 7: + _UC.optType=US_OT_GAP; + break; + case 8: + _UC.optType=US_OT_DIELEC_GAP; + break; + case 9: + _UC.optType=US_OT_MAG; + break; + case 10: + _UC.optType=US_OT_QE; + break; + case 11:/*VER 10.1*/ + _UC.optType=US_OT_2R; + break; + case 14:/*VER 10.1*/ + _UC.optType=US_OT_ZT; + break; + case 17:/*VER 10.1*/ + _UC.optType=US_OT_Fphon; + break; + case 1101: + _UC.optType=US_OT_BULK_M; + break; + case 1102: + _UC.optType=US_OT_SHEAR_M; + break; + case 1103: + _UC.optType=US_OT_YOUNG_M; + break; + case 1104: + _UC.optType=US_OT_POISSON; + break; + case 1105: + _UC.optType=US_OT_PUGH_R; + break; + case 1106: + _UC.optType=US_OT_VICKERS_H; + break; + case 1107: + _UC.optType=US_OT_FRACTURE; + break; + case 1108: + _UC.optType=US_OT_DEBYE_T; + break; + case 1109: + _UC.optType=US_OT_SOUND_V; + break; + case 1110: + _UC.optType=US_OT_SWAVE_V; + break; + case 1111: + _UC.optType=US_OT_PWAVE_V; + break; + default: + _UC.optType=US_OT_UNKNOWN; + } + } else _UC.optType=US_OT_UNKNOWN; + ptr=&(line[0]); + i=0;__COUNT_ALNUM(ptr,i); + if(i>1) {/*multiobjective optimization VER 10.1*/ + if(_UC.new_optType!=NULL) g_free(_UC.new_optType); + _UC.new_optType=g_strdup(line); + }else{ + if(_UC.new_optType!=NULL) g_free(_UC.new_optType); + _UC.new_optType=NULL; } g_free(line); line = file_read_line(vf); @@ -515,8 +639,8 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); for(i=0;i<_UC._nspecies;i++) _UC.atomType[i]=0; ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - if(g_ascii_isdigit(*ptr)) _UC.atomType[i]=(gint)g_ascii_strtod(ptr,NULL);/*user provided Z number*/ + __SKIP_BLANK(ptr); + if(g_ascii_isdigit(*ptr)) _UC.atomType[i]=(gint)g_ascii_strtoull (ptr,NULL,10);/*user provided Z number*/ else _UC.atomType[i]=elem_symbol_test(ptr);/*try user provided symbol*/ if((_UC.atomType[i]<=0)||(_UC.atomType[i]>MAX_ELEMENTS-1)){/*invalid Z*/ _UC.atomType[i]=0;/*allow it for now*/ @@ -547,10 +671,10 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); for(j=0;j<_UC._var_nspecies;j++){ ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - sscanf(ptr,"%i%*s",&(_UC.numSpecies[i+j*_UC._nspecies])); - ptr++;i++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ + __SKIP_BLANK(ptr); + _UC.numSpecies[i+j*_UC._nspecies]=(gint)g_ascii_strtoull(ptr,&ptr2,10); + ptr=ptr2+1; + i++; } g_free(line); line = file_read_line(vf); @@ -559,18 +683,62 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); line = file_read_line(vf); continue; } + if (find_in_string("magRatio",line) != NULL) { + /*a 7 line ratio for magnetic orders VER 10.1*/ + g_free(line);line = file_read_line(vf);/*go next line*/ + ptr=&(line[0]); + i=0;ptr2=ptr; + while((i<7)&&(*ptr!='\n')&&(*ptr!='\0')){ + /*two fromat are accepted: number or number/number*/ + __SKIP_BLANK(ptr); + _UC.magRatio[i]=g_ascii_strtod(ptr,&ptr2); + if(*ptr2=='/'){ + ptr=ptr2; + _UC.magRatio[i]/=g_ascii_strtod(ptr,&ptr2); + } + ptr=ptr2+1; + i++; + } + for(;i<7;i++) _UC.magRatio[i]=0.;/*fill missing values, if any*/ + g_free(line); + line = file_read_line(vf);/*this is the EndMagRatio line*/ + g_free(line); + line = file_read_line(vf); + continue; + } + if (find_in_string("ldaU",line) != NULL) { + /*an array of U values for LDA+U VER 10.1*/ + g_free(line);line = file_read_line(vf);/*go next line*/ + ptr=&(line[0]); + i=0;__COUNT_NUM(ptr,i); + if(i>0){ + ptr=&(line[0]);ptr2=ptr;j=0; + if(_UC.ldaU!=NULL) g_free(_UC.ldaU); + _UC.ldaU=g_malloc(i*sizeof(gdouble)); + while((j bad setting*/ g_free(line); @@ -720,12 +892,12 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); for(i=0;i<_UC._nlatticevalues;i++) _UC.Latticevalues[i]=0.; fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ g_free(line);line = file_read_line(vf);/*go next line*/ - ptr=&(line[0]);i=0; + ptr=&(line[0]);ptr2=ptr;i=0; while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - sscanf(ptr,"%lf%*s",&(_UC.Latticevalues[i])); - ptr++;i++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ + __SKIP_BLANK(ptr); + _UC.Latticevalues[i]=g_ascii_strtod(ptr,&ptr2); + ptr=ptr2+1; + i++; } }else if((_UC._nlatticevalues<=3)&&(_UC._nlatticevalues>1)){/*lattice vectors*/ _UC.Latticevalues = g_malloc(_UC._nlatticevalues*_UC._nlatticevalues*sizeof(gdouble)); @@ -735,12 +907,12 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); ptr=&(line[0]); j=0; while((j<_UC._nlatticevalues)&&(find_in_string("Endvalues",line)==NULL)){ - ptr=&(line[0]);i=0; + ptr=&(line[0]);ptr2=ptr;i=0; while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - sscanf(ptr,"%lf%*s",&(_UC.Latticevalues[i+j*_UC._nlatticevalues])); - ptr++;i++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ + __SKIP_BLANK(ptr); + _UC.Latticevalues[i+j*_UC._nlatticevalues]=g_ascii_strtod(ptr,&ptr2); + ptr=ptr2+1; + i++; } j++; g_free(line); @@ -749,7 +921,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); }else if(_UC._nlatticevalues==1){/*only the volume value*/ _UC.Latticevalues = g_malloc(sizeof(gdouble)); _UC.Latticevalues[0]=0.; - sscanf(ptr,"%lf%*s",&(_UC.Latticevalues[0])); + _UC.Latticevalues[0]=g_ascii_strtod(ptr,NULL); g_free(line); line = file_read_line(vf); }else{/*bad setting*/ @@ -763,6 +935,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); line = file_read_line(vf); continue; } + /*TODO: update III*/ if (find_in_string("splitInto",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ /*count number of splits*/ @@ -913,6 +1086,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); } __GET_INT(repeatForStatistics); __GET_DOUBLE(stopFitness); + __GET_INT(fixRndSeed);/*VER 10.1*/ __GET_BOOL(collectForces); __GET_BOOL(ordering_active); __GET_BOOL(symmetrize); From 50af97afe75a4f4af1de82579b6e633293513051 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 26 Oct 2018 15:10:28 +0900 Subject: [PATCH 33/56] file_uspex: update to USPEX version 10.1 (III) --- src/file_uspex.c | 206 ++++++++++++++++++++++++++++++++++++++--------- src/file_uspex.h | 7 +- 2 files changed, 171 insertions(+), 42 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index bc33d67..bfd9764 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -316,12 +316,13 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ #define __SKIP_BLANK(pointer) while(!g_ascii_isgraph(*pointer)&&(*ptr!='\0')) ptr++ line = file_read_line(vf); /* +++ 1st PASS: get important numbers*/ + _UC._nspecies=0; + _UC._num_opt_steps=0; while(line){ if (find_in_string("atomType",line) !=NULL){ g_free(line);line = file_read_line(vf);/*go next line*/ ptr=&(line[0]); - /*NEW: more safe*/ - _UC._nspecies=0;__COUNT_ALNUM(ptr,_UC._nspecies); + __COUNT_ALNUM(ptr,_UC._nspecies);/*NEW: more safe*/ if(_UC._nspecies<1) _UC._nspecies=1;/*there is at least 1 species*/ g_free(line);line = file_read_line(vf);/*this is the EndAtomType line*/ g_free(line);line = file_read_line(vf); @@ -334,9 +335,8 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ * ie. abinitioCode CANNOT be omited. --ovhpa */ g_free(line);line = file_read_line(vf); ptr=&(line[0]); - /*NEW: more safe*/ - i=0;__COUNT_NUM(ptr,i); - if(i>_UC._num_opt_steps) _UC._num_opt_steps=i; + __COUNT_NUM(ptr,_UC._num_opt_steps);/*NEW: more safe*/ + if(_UC._num_opt_steps<1) _UC._num_opt_steps=1;/*there is at least one step*/ g_free(line);line = file_read_line(vf);/*this is the ENDabinit line*/ g_free(line);line = file_read_line(vf); continue; @@ -345,9 +345,9 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ g_free(line);line = file_read_line(vf); } g_free(line); - if(_UC._nspecies==0){/*this one is mandatory*/ + if(_UC._nspecies==0){/*mandatory*/ if(safe_nspecies==0){ - line = g_strdup_printf("ERROR: Can't read USPEX output: no atom information!\n"); + line = g_strdup_printf("ERROR: Can't read USPEX output: no usable atomType information!\n"); gui_text_show(ERROR, line); g_free(line); fclose(vf); @@ -357,6 +357,13 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ _UC._nspecies=safe_nspecies; } } + if(_UC._num_opt_steps==0){/*also mandatory*/ + line = g_strdup_printf("ERROR: Can't read USPEX output: no usable abinitioCode information!\n"); + gui_text_show(ERROR, line); + g_free(line); + fclose(vf); + return(NULL); + } rewind(vf); /* +++ 2nd PASS: get everything else*/ line = file_read_line(vf); @@ -935,7 +942,6 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); line = file_read_line(vf); continue; } - /*TODO: update III*/ if (find_in_string("splitInto",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ /*count number of splits*/ @@ -953,10 +959,10 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); for(i=0;i<_UC._nsplits;i++) _UC.splitInto[i]=0; ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - sscanf(ptr,"%i%*s",&(_UC.splitInto[i])); - ptr++;i++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ + __SKIP_BLANK(ptr); + _UC.splitInto[i]=(gint)g_ascii_strtoull(ptr,&ptr2,10); + ptr=ptr2+1; + i++; } g_free(line); line = file_read_line(vf);/*this is the EndSplitInto line*/ @@ -971,10 +977,10 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); for(i=0;i<_UC._num_opt_steps;i++) _UC.abinitioCode[i]=0; ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ - if((*ptr==' ')||(*ptr=='(')) while((*ptr==' ')||(*ptr=='(')) ptr++;/*skip space(s) & parenthesis*/ - sscanf(ptr,"%i%*s",&(_UC.abinitioCode[i])); - ptr++;i++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end (skip ')' if any)*/ + __SKIP_BLANK(ptr); + _UC.abinitioCode[i]=(gint)g_ascii_strtoull(ptr,&ptr2,10); + ptr=ptr2+1; + i++; } g_free(line); line = file_read_line(vf);/*this is the ENDabinit line*/ @@ -989,10 +995,10 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); for(i=0;i<_UC._num_opt_steps;i++) _UC.KresolStart[i]=0.; ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - sscanf(ptr,"%lf%*s",&(_UC.KresolStart[i])); - ptr++;i++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ + __SKIP_BLANK(ptr); + _UC.KresolStart[i]=g_ascii_strtod(ptr,&ptr2); + ptr=ptr2+1; + i++; } g_free(line); line = file_read_line(vf);/*this is the Kresolend line*/ @@ -1007,10 +1013,10 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); for(i=0;i<_UC._num_opt_steps;i++) _UC.vacuumSize[i]=10.;/*implicit is 10.*/ ptr=&(line[0]);i=0; while((*ptr!='\n')&&(*ptr!='\0')){ - if(*ptr==' ') while(*ptr==' ') ptr++;/*skip space(s)*/ - sscanf(ptr,"%lf%*s",&(_UC.vacuumSize[i])); - ptr++;i++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ + __SKIP_BLANK(ptr); + _UC.vacuumSize[i]=g_ascii_strtod(ptr,&ptr2); + ptr=ptr2+1; + i++; } g_free(line); line = file_read_line(vf);/*this is the endVacuumSize line*/ @@ -1019,6 +1025,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); continue; } __GET_INT(numParallelCalcs); +/*UPDATE III*/ if (find_in_string("commandExecutable",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ /*there is also 1 Date: Fri, 26 Oct 2018 17:49:15 +0900 Subject: [PATCH 34/56] file_uspex: update to USPEX version 10.1 (IV) --- src/file_uspex.c | 233 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 188 insertions(+), 45 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index bfd9764..b5a68dc 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -273,6 +273,8 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ /*this should be promoted*/ #define __Q(a) #a /*some lazy defines*/ +#define __STRIP_EOL(line) for(i=0;i1) {/*multiobjective optimization VER 10.1*/ - if(_UC.new_optType!=NULL) g_free(_UC.new_optType); - _UC.new_optType=g_strdup(line); - }else{ - if(_UC.new_optType!=NULL) g_free(_UC.new_optType); - _UC.new_optType=NULL; + if(_UC.new_optType!=NULL){ + g_free(line); + line = file_read_line(vf);/*This is the EndOptType line*/ } g_free(line); line = file_read_line(vf); continue; + /*TODO: assign a count of optType values in case of Multiobjective optimization*/ } if (find_in_string("atomType",line) !=NULL){ g_free(line);line = file_read_line(vf);/*go next line*/ @@ -1025,7 +1043,6 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); continue; } __GET_INT(numParallelCalcs); -/*UPDATE III*/ if (find_in_string("commandExecutable",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ /*there is also 1 MagRatio mandatory*/ + __OUT_BK_DOUBLE(magRatio,"EndMagRatio",7); + } + if(_UC.ldaU!=NULL){ + /*VER 10.1: LDA+U values per species*/ + __OUT_BK_DOUBLE(ldaU,"EndLdaU",_UC._nspecies); + } if(_UC.calculationMethod==US_CM_META) __OUT_DOUBLE(ExternalPressure); if(_UC.ExternalPressure!=0.) __OUT_DOUBLE(ExternalPressure); /*print when NOT default or unset*/ @@ -1703,6 +1792,7 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ if(_UC.goodBonds!=NULL) __OUT_TMAT_DOUBLE(goodBonds,"EndGoodBonds",_UC._nspecies);/*TODO: use of a single value is unsupported*/ if(!_UC.checkMolecules) __OUT_BOOL(checkMolecules); if(_UC.checkConnectivity) __OUT_BOOL(checkConnectivity); + if(_UC.fitLimit!=0.) __OUT_DOUBLE(fitLimit);/*VER 10.1*/ vfpos=ftell(vf);/* flag */ is_w=0; line=g_strdup_printf("* POPULATION *"); @@ -1730,6 +1820,7 @@ is_w=0; if(_UC.symmetries!=NULL) __OUT_BK_STRING(symmetries,"endSymmetries"); if(_UC.fracGene!=0.5) __OUT_DOUBLE(fracGene); if(_UC.fracRand!=0.2) __OUT_DOUBLE(fracRand); + if(_UC.fracTopRand!=0.2) __OUT_DOUBLE(fracTopRand);/*VER 10.1*/ if((_UC._nspecies>1)&&(_UC.fracPerm!=0.1)) __OUT_DOUBLE(fracPerm); if((_UC._nspecies==1)&&(_UC.fracPerm!=0.)) __OUT_DOUBLE(fracPerm); if(_UC.fracAtomsMut!=0.1) __OUT_DOUBLE(fracAtomsMut); @@ -1743,6 +1834,7 @@ is_w=0; }else{ if(_UC.fracLatMut!=0.1) __OUT_DOUBLE(fracLatMut); } + if(_UC.fracSpinMut!=0.1) __OUT_DOUBLE(fracSpinMut);/*VER 10.1*/ if(_UC.howManySwaps!=0) __OUT_INT(howManySwaps); if(_UC.specificSwaps!=NULL) __OUT_BK_STRING(specificSwaps,"EndSpecific"); if(_UC.mutationDegree!=0.) __OUT_DOUBLE(mutationDegree); @@ -1823,10 +1915,9 @@ is_w=0; line=g_strdup_printf("* DEVELOPERS *"); __TITLE(line); g_free(line); - if(_UC.repeatForStatistics!=1) { - __OUT_INT(repeatForStatistics); - if(_UC.stopFitness!=0.) __OUT_DOUBLE(stopFitness); - } + if(_UC.repeatForStatistics!=1) __OUT_INT(repeatForStatistics); + if(_UC.stopFitness!=0.) __OUT_DOUBLE(stopFitness);/*not necessarily used with repeatForStatistics?*/ + if(_UC.fixRndSeed!=0) __OUT_INT(fixRndSeed);/*VER 10.1*/ if(_UC.collectForces) __OUT_BOOL(collectForces); if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ @@ -1847,6 +1938,36 @@ is_w=0; if(_UC.numberparents!=2) __OUT_INT(numberparents); if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* BOLTZTRAP *");/*VER 10.1*/ + __TITLE(line); + g_free(line); + if(_UC.BoltzTraP_T_max!=800.0) __OUT_DOUBLE(BoltzTraP_T_max); + if(_UC.BoltzTraP_T_delta!=50.0) __OUT_DOUBLE(BoltzTraP_T_delta); + if(_UC.BoltzTraP_T_efcut!=0.15) __OUT_DOUBLE(BoltzTraP_T_efcut); + if(_UC.TE_T_interest!=300.0) __OUT_DOUBLE(TE_T_interest); + if(_UC.TE_threshold!=0.5) __OUT_DOUBLE(TE_threshold); + if(_UC.TE_goal!=US_BT_ZT) { + switch (_UC.TE_goal){ + case US_BT_ZT:/*we should never get there...*/ + fprintf(vf,"ZT\t: TE_goal\n");is_w++; + break; + case US_BT_ZTxx: + fprintf(vf,"ZT_xx\t: TE_goal\n");is_w++; + break; + case US_BT_ZTyy: + fprintf(vf,"ZT_yy\t: TE_goal\n");is_w++; + break; + case US_BT_ZTzz: + fprintf(vf,"ZT_zz\t: TE_goal\n");is_w++; + break; + case US_BT_UNKNOWN: + default: + fprintf(vf,"???\t: TE_goal (unsupported keyword)\n");is_w++; + } + } +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ is_w=0; line=g_strdup_printf("* SURFACES *"); __TITLE(line); @@ -1881,7 +2002,7 @@ is_w=0; if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; - line=g_strdup_printf("* PARTICLE SWARM OPTIMIZATION *"); + line=g_strdup_printf("* PARTICLE SWARM OPTIMIZATION (PSO) *"); __TITLE(line); g_free(line); if(_UC.PSO_softMut!=1.) __OUT_DOUBLE(PSO_softMut); @@ -1890,7 +2011,9 @@ is_w=0; if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; - line=g_strdup_printf("* VCNEB *"); + line=g_strdup_printf("* VARIABLE-CELL NEB (VCNEB) *"); + __TITLE(line); + g_free(line); if(_UC.vcnebType!=110) __OUT_INT(vcnebType); if(_UC.numImages!=9) __OUT_INT(numImages); if(_UC.numSteps!=200) __OUT_INT(numSteps); @@ -1911,6 +2034,26 @@ is_w=0; if(_UC.FormatType!=2) __OUT_INT(FormatType); if(_UC.PrintStep!=1) __OUT_INT(PrintStep); if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* TRANSITION PATH SAMPLING (TPS) *");/*VER 10.1*/ + __TITLE(line); + g_free(line); + if(_UC.numIterations!=1000) __OUT_INT(numIterations); + if(_UC.speciesSymbol!=NULL) __OUT_BK_STRING(speciesSymbol,"EndSpeciesSymbol"); + if(_UC.mass!=NULL) __OUT_BK_DOUBLE(mass,"endMass",_UC._nspecies); + if((_UC.amplitudeShoot[0]!=0.10)&&(_UC.amplitudeShoot[1]!=0.10)) __OUT_BK_DOUBLE(amplitudeShoot,"EndAmplitudeShoot",2); + if((_UC.magnitudeShoot[0]!=1.05)&&(_UC.magnitudeShoot[1]!=1.05)) __OUT_BK_DOUBLE(magnitudeShoot,"EndMagnitudeShoot",2); + if(_UC.shiftRatio!=0.1) __OUT_DOUBLE(shiftRatio); + if(!_UC.orderParaType) __OUT_BOOL(orderParaType); + if((_UC.opCriteria[0]!=0.)&&(_UC.opCriteria[1]!=0.)) __OUT_BK_DOUBLE(opCriteria,"EndOpCriteria",2); + if(_UC.cmdOrderParameter!=NULL) __OUT_BK_STRING(cmdOrderParameter,"EndCmdOrderParameter"); + if(_UC.cmdEnthalpyTemperature!=NULL) __OUT_BK_STRING(cmdEnthalpyTemperature,"EndCmdEnthalpyTemperature"); + if(_UC.orderParameterFile!=NULL) __OUT_STRING(orderParameterFile); + if(_UC.enthalpyTemperatureFile!=NULL) __OUT_STRING(enthalpyTemperatureFile); + if(_UC.trajectoryFile!=NULL) __OUT_STRING(trajectoryFile); + if(_UC.MDrestartFile!=NULL) __OUT_STRING(MDrestartFile); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ line=g_strdup_printf("* END OF FILE *"); __TITLE(line); From 8021b18b498418e7ea401b411f70810e5c9527c7 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 29 Oct 2018 21:47:49 +0900 Subject: [PATCH 35/56] file_uspex: update to USPEX version 10.1 (V) + massive changes to file_uspex (1/2) + gl_graph cross symbols for missing data --- src/file_uspex.c | 1342 +++++++++++++++++++++++++--------------------- src/file_uspex.h | 18 +- src/gl_graph.c | 72 ++- src/graph.h | 2 + src/gui_uspex.c | 4 +- 5 files changed, 817 insertions(+), 621 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index b5a68dc..9151ce0 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -476,9 +476,9 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); __SKIP_BLANK(ptr); /*in ANY case we still load the first value as old optType*/ if(g_ascii_isalpha(*ptr)){ + j=0; if((*ptr=='m')||(*ptr=='M')){ /*could be Min max*/ - j=0; if((*(ptr+1)=='a')&&(*(ptr+2)=='x')) { /*can be mag_moment -> checked x*/ j=1; @@ -1391,8 +1391,8 @@ fprintf(stdout,"#DBG: PROBE FAIL LINE: %s",line); #undef __GET_DOUBLE #undef __GET_STRING #undef __GET_CHARS -#undef __COUNT_ALNUM -#undef __COUNT_NUM +//#undef __COUNT_ALNUM +//#undef __COUNT_NUM } void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ gint i; @@ -2083,103 +2083,180 @@ else vfpos=ftell(vf);/* flag */ #undef __OUT_BK_STRING #undef __OUT_TMAT_DOUBLE } -/*******************************/ -/* Read Individual format file */ -/*******************************/ +/************************/ +/* NEW Read Individuals */ +/************************/ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ - FILE *vf; - long int vfpos; - gchar *line=NULL; - uspex_output_struct *uspex_output=model->uspex; - /* specific */ - gint idx=0; + FILE *vf; + gchar *line=NULL; + uspex_output_struct *uspex_output=model->uspex; + /* specific */ gchar *ptr; - gint max_struct=0; - gint red_index; - /*since energy is sometimes eV, and sometimes eV/atom ?*/ - gboolean e_red=FALSE; + gchar *ptr2; + gint gen; + gint idx,jdx; + gboolean e_red=FALSE;/*FALSE -> eV ; TRUE -> eV/atom*/ /*start*/ - vf = fopen(filename, "rt"); - if (!vf) return 1; - /*Have fitness? Better watch for each case...*/ - /*^^^^ I thought that calculationMethod = USPEX => fitness, but got defeated by EX19*/ + vf = fopen(filename, "rt"); + if (!vf) return -1;/*fail*/ line = file_read_line(vf); - if (find_in_string("Fitness",line) != NULL) _UO.have_fitness=TRUE; - else _UO.have_fitness=FALSE; - rewind(vf); - /* deal with the problematic units */ - if(fetch_in_file(vf,"eV/atom")!=0) e_red=TRUE; - rewind(vf); - /* Skip header: FIX a _BUG_ when Individuals file sometimes has 2 line and sometimes only 1 */ - vfpos=ftell(vf);/* flag */ - line = file_read_line(vf); - while(line){ - ptr=&(line[0]); - while(*ptr==' ') ptr++; - if(g_ascii_isdigit(*ptr)) { - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - break; - } - vfpos=ftell(vf);/* flag */ - g_free(line); - line = file_read_line(vf); - } - if(line==NULL) return -1; - /* META calculation have a gen=0 Individual - unfortunately, it is *not* in the gather- - -POSCARS file, so we ignore gen=0 for now. */ - if(_UO.calc->calculationMethod==US_CM_META){ - g_free(line); - line = file_read_line(vf); - vfpos=ftell(vf);/* flag */ + _UO.have_fitness=FALSE; + _UO.have_supercell=FALSE; +// if(find_in_string("Fitness",line) != NULL) _UO.have_fitness=TRUE; + if(find_in_string("SuperCell",line) !=NULL){ + /*it's not about natoms, it's about supercell*/ + _UO.have_supercell=TRUE; } - /*do a 1st pass to count stuctures*/ - _UO.num_struct=0; - while (line){ - _UO.num_struct++; - sscanf(line," %*i %i %*s",&idx); - if(idx>max_struct) max_struct=idx; +/* Fitness is currently not activated due to a lack of consitency with some results */ + if (find_in_string("eV/atom",line) != NULL) e_red=TRUE; + g_free(line); + line = file_read_line(vf); + if (find_in_string("eV/atom",line) != NULL) e_red=TRUE;/*just in case it's on the second line*/ + ptr=&(line[0]); + __SKIP_BLANK(ptr); + while(!g_ascii_isdigit(*ptr)){ + /*skip additionnal header lines*/ g_free(line); line = file_read_line(vf); + ptr=&(line[0]); + __SKIP_BLANK(ptr); } - _UO.num_struct--; - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - g_free(line); - line = file_read_line(vf); - /* now prepare arrays <- JOB=USPEX/300 example */ - if(_UO.num_struct==0) return 1; - _UO.red_index=g_malloc(max_struct*sizeof(gint)); - for(idx=0;idx_UO.num_gen) _UO.num_gen=gen; + ptr=ptr2+1; + __SKIP_BLANK(ptr); + /*get index*/ + idx=(gint)g_ascii_strtoull(ptr,&ptr2,10); + if(ptr2==NULL) goto end_loop_ind; +#if DEBUG_USPEX_READ +fprintf(stdout,"idx=%i ",idx); +#endif + _UO.ind[idx].gen=gen; + ptr=ptr2+1; + /*jump to [ ... ] part*/ + while((*ptr!='[')&&(*ptr!='\0')) ptr++; + if(*ptr=='\0') goto end_loop_ind; + _UO.ind[idx].natoms=0;ptr2=ptr;jdx=0; +#if DEBUG_USPEX_READ +fprintf(stdout,"[ "); +#endif +if(!_UO.have_supercell){ + while((ptr2!=NULL)&&(*ptr2!='\0')&&(jdx<_UO.calc->_nspecies)){ + ptr=ptr2+1; + __SKIP_BLANK(ptr); + _UO.ind[idx].atoms[jdx]=(gint)g_ascii_strtoull(ptr,&ptr2,10); +#if DEBUG_USPEX_READ +fprintf(stdout,"%i ",_UO.ind[idx].atoms[jdx]); +#endif + _UO.ind[idx].natoms+=_UO.ind[idx].atoms[jdx]; + jdx++; + } + if(*ptr2=='\0') goto end_loop_ind; +#if DEBUG_USPEX_READ +fprintf(stdout,"] natm=%i ",_UO.ind[idx].natoms); +#endif + ptr=ptr2+1; + __SKIP_BLANK(ptr); }else{ - sscanf(line," %i %i%*[^[][%*[^]]] %lf %lf %*s", - &(_UO.ind[idx].gen),&(red_index),&(_UO.ind[idx].energy),&(_UO.ind[idx].volume)); + /*supercell automagic*/ + ptr=ptr2+1; + while((*ptr!=']')&&(*ptr!='\0')){ + __SKIP_BLANK(ptr); + jdx+=(gint)g_ascii_strtoull(ptr,&ptr2,10); + ptr=ptr2+1; + __SKIP_BLANK(ptr); + } + _UO.ind[idx].natoms=jdx;/*temporary*/ +#if DEBUG_USPEX_READ +fprintf(stdout," x%i ] ",_UO.ind[idx].natoms); +#endif } - if(_UO.calc->calculationMethod==US_CM_META) red_index--;/*because of META "special" numbering*/ - if(_UO.ind[idx].gen<_UO.num_gen) _UO.ind[idx].gen++; - if(_UO.ind[idx].gen>_UO.num_gen) _UO.num_gen=_UO.ind[idx].gen; -/*_VALGRIND_BUG_: _UO.red_index[red_index]=idx;*/ - _UO.red_index[red_index-1]=idx; + /*we should be at *ptr==']' (hopefully)*/ + if(*ptr==']') ptr++; + __SKIP_BLANK(ptr); + /*get enthalpy*/ + _UO.ind[idx].energy=g_ascii_strtod(ptr,&ptr2); + if(ptr2==NULL) goto end_loop_ind; +#if DEBUG_USPEX_READ +fprintf(stdout,"e=%lf ",_UO.ind[idx].energy); +#endif if(!e_red) _UO.ind[idx].E=_UO.ind[idx].energy/_UO.ind[idx].natoms; else _UO.ind[idx].E=_UO.ind[idx].energy; #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX[Individual]: GEN=%i STRUCT=%i e=%lf E=%lf\n",_UO.ind[idx].gen,idx+1,_UO.ind[idx].energy,_UO.ind[idx].E); +fprintf(stdout,"e/atm=%lf ",_UO.ind[idx].E); #endif if(_UO.ind[idx].E<_UO.min_E) _UO.min_E=_UO.ind[idx].E; if(_UO.ind[idx].E>_UO.max_E) _UO.max_E=_UO.ind[idx].E; + ptr=ptr2+1; + __SKIP_BLANK(ptr); + /*get volume*/ + _UO.ind[idx].volume=g_ascii_strtod(ptr,&ptr2); + if(ptr2==NULL) goto end_loop_ind; +#if DEBUG_USPEX_READ +fprintf(stdout,"v=%lf ",_UO.ind[idx].volume); +#endif + /*from this point we can say that we have data*/ + _UO.ind[idx].have_data=TRUE; + if(_UO.calc->calculationMethod==US_CM_META) goto get_symmetry; + if(_UO.calc->calculationMethod==US_CM_MINHOP) goto get_symmetry; + ptr=ptr2+1; + __SKIP_BLANK(ptr); + /*get density -- example 19 will fail here! (USPEX 10.0.0)*/ + _UO.ind[idx].density=g_ascii_strtod(ptr,&ptr2); + if(ptr2==NULL) goto end_loop_ind; +#if DEBUG_USPEX_READ +fprintf(stdout,"d=%lf ",_UO.ind[idx].density); +#endif + ptr=ptr2+1; + __SKIP_BLANK(ptr); + /*get fitness*/ + _UO.ind[idx].fitness=10000; + _UO.ind[idx].fitness=g_ascii_strtod(ptr,&ptr2); + if(ptr2==NULL) goto end_loop_ind; +#if DEBUG_USPEX_READ +fprintf(stdout,"f=%lf ",_UO.ind[idx].fitness); +#endif + if(_UO.ind[idx].fitness<_UO.min_F) _UO.min_F=_UO.ind[idx].fitness; + if(_UO.ind[idx].fitness>_UO.max_F) _UO.max_F=_UO.ind[idx].fitness; + ptr=ptr2+1; + __SKIP_BLANK(ptr); + /*get SYMM (skip KPOINTS)*/ +get_symmetry: + while((*ptr!=']')&&(*ptr!='\0')) ptr++; + if(*ptr=='\0') goto end_loop_ind; + ptr++; + __SKIP_BLANK(ptr); + _UO.ind[idx].symmetry=(gint)g_ascii_strtoull(ptr,NULL,10); +#if DEBUG_USPEX_READ +fprintf(stdout,"sym=%i ",_UO.ind[idx].symmetry); +#endif + /*-> ignore the "N/A" possibility on symmetry*/ +end_loop_ind: +#if DEBUG_USPEX_READ +fprintf(stdout,"\n"); +#endif g_free(line); line = file_read_line(vf); - idx++; } - /*all done*/ return 0; } /**********************************************************************************/ @@ -2194,29 +2271,33 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ gchar *ptr2; gchar *res_folder; gchar *aux_file; - gint probe;/*valgrind check*/ - gint ix; + gint ix,iix; gint idx; gint jdx; gint min,max,med; - gint job; - /* results */ - FILE *f_src; - FILE *f_dest; + uspex_method method; + gint nspecies; + gint num; + gint atom_per_supercell; + gint max_num_p; + gint max_num_i; + gint n_data; + /*graph*/ + gboolean isok;/*FIX valgrind _BUG_*/ + gint gen; gdouble *e; + gdouble min_E; + gdouble max_E; + /*compo*/ + gint n_compo; + gint c_sum; gdouble *c; gdouble *tag; - gdouble *tmp; - gdouble compo; - gint n_compo; - gint skip=0; - gint gen=1; - gint num; - gint natoms; gint species_index; - gdouble min_E; - gdouble min_F=0.; - gdouble max_E; + /* results */ + FILE *f_src; + FILE *f_dest; + gint natoms; gchar *atoms; uspex_output_struct *uspex_output; uspex_calc_struct *uspex_calc; @@ -2233,9 +2314,13 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ if(model->uspex!=NULL) g_free(model->uspex); model->uspex=g_malloc(sizeof(uspex_output_struct)); uspex_output=model->uspex; - /* TODO: check that selected file is OUTPUT.txt */ vf = fopen(filename, "rt"); - if (!vf) return 1; + if (!vf) { + line = g_strdup_printf("ERROR: Can't open USPEX OUTPUT.txt file!\n"); + gui_text_show(ERROR, line); + g_free(line); + return -1; + } error_table_clear(); /* --- get result folder*/ res_folder=g_strdup (filename); @@ -2247,115 +2332,109 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ /* --- setup environment */ sysenv.render.show_energy = TRUE; -/* --- read the system OUTPUT.txt (will be confirmed by Parameters.txt)*/ - if(fetch_in_file(vf,"Version")==0){ - /*can't get version number (10.0.0 example will fail here)*/ - /* -> just produce a warning... file might actually be processed correctly*/ - line = g_strdup_printf("WARNING: USPEX version unsupported!\n"); - gui_text_show(WARNING, line); - g_free(line); - }else{ - rewind(vf); - line = file_read_line(vf); - while(line) { - if (find_in_string("Version",line) != NULL){ - sscanf(line,"| Version %i.%i.%i %*s",&(max),&(med),&(min)); - _UO.version=min+10*med+100*max; - if(_UO.version!=944){ - g_free(line); - line = g_strdup_printf("WARNING: USPEX version %i unsupported!\n",_UO.version); - gui_text_show(WARNING, line); - - } +/* --- read the system OUTPUT.txt - actually only read Version, {VCNEB,TPS}, and nspecies*/ + _UO.version=0;method=US_CM_UNKNOWN;nspecies=0; + line = file_read_line(vf); + while(line) { + ptr=NULL; + ptr=find_in_string("Version",line); + if(ptr!=NULL){ + /*we find version tag*/ + while((*ptr!='\0')&&(!g_ascii_isdigit(*ptr))) ptr++; + if(!g_ascii_isdigit(*ptr)){/*malformed Version tag*/ g_free(line); - break; + line = g_strdup_printf("WARNING: wrong USPEX Version tag!\n"); + gui_text_show(WARNING, line); + }else{ + min=0;med=0;max=0; + ptr2=NULL; + max=g_ascii_strtoull(ptr,&ptr2,10); + ptr=NULL; + if(ptr2!=NULL) med=(gint)g_ascii_strtoull(ptr2+1,&ptr,10); + if(ptr!=NULL) min=(gint)g_ascii_strtoull(ptr+1,NULL,10); + _UO.version=min+10*med+100*max; } g_free(line); line = file_read_line(vf); + continue; + } + ptr=find_in_string("- USPEX",line); + if(ptr!=NULL){ + /* Version 10.0.0 have a strange format: + * USPEX 10.0.0 (mm/dd/yyyy) + * so we need to check for this one too.*/ + ptr=ptr+2; + while((*ptr!='\0')&&(!g_ascii_isdigit(*ptr))) ptr++; + if(!g_ascii_isdigit(*ptr)){/*malformed Version tag*/ + /*but we IGNORE it since it can be a valid tag which is not a Version*/ + }else{ + min=0;med=0;max=0; + ptr2=NULL; + max=g_ascii_strtoull(ptr,&ptr2,10); + ptr=NULL; + if(ptr2!=NULL) med=(gint)g_ascii_strtoull(ptr2+1,&ptr,10); + if(ptr!=NULL) min=(gint)g_ascii_strtoull(ptr+1,NULL,10); + _UO.version=min+10*med+100*max; + } + g_free(line); + line = file_read_line(vf); + continue; + } + if(find_in_string("VCNEB",line) != NULL) { + method=US_CM_VCNEB; + g_free(line); + line = file_read_line(vf); + continue; + } + if(find_in_string("Transition Path Sampling",line) != NULL) {/*VER 10.1*/ + method=US_CM_TPS; + g_free(line); + line = file_read_line(vf); + continue; + } + if(find_in_string("types of atoms in the system",line) != NULL){ + /*detect nspecies*/ + ptr=&(line[0]); + while((*ptr!='\0')&&(!g_ascii_isdigit(*ptr))) ptr++; + if(!g_ascii_isdigit(*ptr)){/*malformed atom type tag*/ + /*let's ignore*/ + }else{ + nspecies=(gint)g_ascii_strtoull(ptr,NULL,10); + } + g_free(line); + line = file_read_line(vf); + continue; } - } - rewind(vf); - job=0; - if(fetch_in_file(vf,"Block for system description")==0) { -/*since VCNEB will fail here due to a non-unified OUTPUT.txt format - *we need to be a little more permissive... */ - rewind(vf); - if(fetch_in_file(vf,"VCNEB")==0) goto uspex_fail;/*definitely wrong*/ - job=-1; - } -if(job>-1){ - /*next line contains Dimensionality*/ - ix=0; - line = file_read_line(vf); - /*unless from a previous version and it contains a lot of '-' character*/ - if (find_in_string("Dimensionality",line) == NULL) { g_free(line); line = file_read_line(vf); } - sscanf(line," Dimensionality : %i ",&(ix)); - switch (ix){/*to be use later*/ - case -2: - /*we do not deal with 2D crystal yet*/ - case 0: - case 1: - case 2: - case 3: - _UO.dim=ix; - break; - default: - line = g_strdup_printf("ERROR: reading USPEX OUTPUT.txt file!\n"); - gui_text_show(ERROR, line); - g_free(line); - goto uspex_fail; - } - job=ix*100; - g_free(line); - /*next line contains Molecular*/ - line = file_read_line(vf); - sscanf(line," Molecular : %i %*s",&(ix)); - job+=(ix*10); - if(ix==0) _UO.mol=FALSE; - else if(ix==1) _UO.mol=TRUE; - else{ - line = g_strdup_printf("ERROR: reading USPEX OUTPUT.txt file!\n"); - gui_text_show(ERROR, line); - g_free(line); - goto uspex_fail; - } - g_free(line); - /*next line contains Variable Composition*/ - line = file_read_line(vf); - sscanf(line," Variable Composition : %i %*s",&(ix)); - job+=ix; - if(ix==0) _UO.var=FALSE; - else if(ix==1) _UO.var=TRUE; - else{ - line = g_strdup_printf("ERROR: reading USPEX OUTPUT.txt file!\n"); - gui_text_show(ERROR, line); - g_free(line); - goto uspex_fail; - } + if(line!=NULL) g_free(line); #if DEBUG_USPEX_READ - fprintf(stdout,"#DBG: USPEX OUTPUT calculationType=%i\n",job); +fprintf(stdout,"#DBG: FILE: %s VERS: %i NSPE: %i\n",filename,_UO.version,nspecies); #endif - g_free(line); -}/*in case of VCNEB, we don't have a correct job number*/ - line = file_read_line(vf); - num=0; - while(line){ - if(find_in_string("types of atoms in the system",line) != NULL) { - /**/ - sscanf(line," There are %i %*s",&(num)); - } - g_free(line); - line = file_read_line(vf); + if(_UO.version==0){ + line=g_strdup_printf("USPEX version undetected!\n"); + gui_text_show(ERROR, line); + }else if(_UO.version==944){ + line=g_strdup_printf("USPEX version %i detected!\n",_UO.version); + gui_text_show(STANDARD, line); + }else if(_UO.version==1010){ + line=g_strdup_printf("USPEX new version %i detected!\n",_UO.version); + gui_text_show(STANDARD, line); + }else{ + line=g_strdup_printf("USPEX unsupported version %i detected!\n",_UO.version); + gui_text_show(WARNING, line); } g_free(line); + if((method==US_CM_UNKNOWN)&&(nspecies==0)){ + line=g_strdup_printf("USPEX OUTPUT.txt is missing nspecies information!\n"); + gui_text_show(WARNING, line); + } /* --- and close */ fclose(vf);vf=NULL; /* --- READ Parameters.txt */ aux_file = g_strdup_printf("%s%s",res_folder,"Parameters.txt"); - _UO.calc=read_uspex_parameters(aux_file,num); + _UO.calc=read_uspex_parameters(aux_file,nspecies); if(_UO.calc==NULL){ line = g_strdup_printf("ERROR: reading USPEX REAL Parameter.txt file!\n"); gui_text_show(ERROR, line); @@ -2366,335 +2445,410 @@ if(job>-1){ g_free(aux_file); uspex_calc=_UO.calc; _UC.path=g_strdup(res_folder); -/* --- CHECK type from Parameters.txt matches that of OUTPUT.TXT */ - if((job!=-1)&&(job!=_UC.calculationType)){ -/*since VCNEB will fail here due to a non-unified OUTPUT.txt format - *we need to be a little more permissive... */ - line = g_strdup_printf("ERROR: inconsistent USPEX files (%i!=%i)!\n",job,_UC.calculationType); +/* --- ANYTHING but VCNEB, and TPS (and unsupported)*/ +if((_UC.calculationMethod==US_CM_USPEX) + ||(_UC.calculationMethod==US_CM_META) + ||(_UC.calculationMethod==US_CM_PSO) + ||(_UC.calculationMethod==US_CM_MINHOP)){ +/* +++ check gatheredPOSCARS*/ + if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); + else aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); + vf = fopen(aux_file, "rt"); + if (!vf) { + if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS_relaxed file!\n"); + else line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS file!\n"); gui_text_show(ERROR, line); g_free(line); + g_free(aux_file); goto uspex_fail; } -if((_UC.calculationMethod==US_CM_USPEX)||(_UC.calculationMethod==US_CM_META)){ -/* --- if calculationMethod={USPEX,META} */ - g_free(model->basename);/*FIX: _VALGRIND_BUG_*/ + strcpy(model->filename,aux_file);// which means that we "forget" about OUTPUT.txt + g_free(aux_file); + /*seems good so far*/ + g_free(model->basename); model->basename=g_strdup_printf("uspex"); -/* we have to open structure file first because of inconsistency in atom reporting in Individuals file*/ -/* --- READ gatheredPOSCARS <- this is going to be the main model file */ -/* ^^^ META is ill-defined: read first gatheredPOSCARS, then update with gatheredPOSCARS_relaxed in the future TODO*/ - aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); - vf = fopen(aux_file, "rt"); - if (!vf) { - if(_UO.ind!=NULL) g_free(_UO.ind); - line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS file!\n"); - gui_text_show(ERROR, line); - g_free(line); - goto uspex_fail; - } - /*count number of structures*/ - _UO.num_struct=0; + model->num_frames=0; +/* +++ register frames, calculate max_struct (according to gatherPOSCARS - it can change)*/ + num=0;max_num_p=0; + vfpos=ftell(vf);/* flag */ +/* +++ frame_0 exists (but is not part of gathered_POSCARS) in case of META calculation*/ + /*for now, just duplicate the first one (until we find out if this information is available somewhere in results)*/ + add_frame_offset(vf, model); + model->num_frames++; line = file_read_line(vf); - while(!feof(vf)){ - if((line[0]=='E')&&(line[1]=='A')) _UO.num_struct++; +/* +++ in case of supercell calculation, we need to get a real natoms, and rescale accordingly*/ + idx=0; + while((idx<6)&&(!feof(vf))){ + idx++; g_free(line); line = file_read_line(vf); } + atom_per_supercell=0; + ptr=&(line[0]); + while((*ptr!='\0')&&(*ptr!='\n')){ + __SKIP_BLANK(ptr); + atom_per_supercell+=(gint)g_ascii_strtoull(ptr,&ptr2,10); + ptr=ptr2+1; + } + /*all done*/ + num=0; rewind(vf); - model->num_frames=0; - vfpos=ftell(vf);/* flag */ - line = file_read_line(vf); - _UO.ind=g_malloc((_UO.num_struct)*sizeof(uspex_individual)); - idx=0;ix=-1; - while(!feof(vf)){ - if((line[0]=='E')&&(line[1]=='A')) { - idx=0;ix++; - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - add_frame_offset(vf, model); - model->num_frames++; - g_free(line); - line = file_read_line(vf); - } - if(idx==5){/*calculate number of species and atoms*/ - _UO.ind[ix].atoms=g_malloc(_UC._nspecies*sizeof(gint)); - for(jdx=0;jdx<_UC._nspecies;jdx++) _UO.ind[ix].atoms[jdx]=0;/*init atoms*/ - _UO.ind[ix].natoms=0; - /*get this structure nspecies*/ - ptr=&(line[0]); - while(*ptr==' ') ptr++;/*skip initial space (if any)*/ - jdx=1;/*there is at least one species*/ - while(*ptr!='\0'){ - if(*ptr==' ') { - jdx++;ptr++; - while(*ptr==' ') ptr++;/*skip space*/ - }else ptr++; - } - if(jdx<_UC._nspecies){ - gchar *line2;/*double buffer*/ - /*we need to know which species is here*/ - line2 = file_read_line(vf); - ptr=&(line[0]); - ptr2=&(line2[0]); - idx++; - jdx=0; - while(*ptr==' ') ptr++;/*skip initial space (if any)*/ - while(*ptr2==' ') ptr2++;/*skip initial space (if any)*/ - while((*ptr!='\0')&&(*ptr2!='\0')){ - /*get the correct jdx number*/ - jdx=0;/*we reset jdx to cope with 'OUT OF ORDER' poscar species, if any*/ - while((jdx<_UC._nspecies)&&(_UC.atomType[jdx]!=elem_symbol_test(ptr))) jdx++; - _UO.ind[ix].atoms[jdx]=(gint)g_ascii_strtod(ptr2,NULL); - _UO.ind[ix].natoms+=_UO.ind[ix].atoms[jdx]; - ptr++;ptr2++; - while(g_ascii_isgraph(*ptr)) ptr++;/*go to next space/end*/ - while(g_ascii_isgraph(*ptr2)) ptr2++;/*go to next space/end*/ - ptr++;ptr2++; - while(*ptr==' ') ptr++;/*skip space*/ - while(*ptr2==' ') ptr2++;/*skip space*/ - } - g_free(line); - line=line2; - }else{ - /*get a new line (the number of each atoms)*/ - g_free(line); - line = file_read_line(vf); - idx++; - ptr=&(line[0]); - ptr2=ptr;jdx=0; - do{/*get the number of each species (in the Parameters.txt order)*/ -/*_VALGRIND_BUG_: _UO.ind[ix].atoms[jdx]=g_ascii_strtod(ptr,&ptr2);*/ - probe=(gint)g_ascii_strtod(ptr,&ptr2); - if(ptr2==ptr) break; - _UO.ind[ix].atoms[jdx]=probe; - _UO.ind[ix].natoms+=_UO.ind[ix].atoms[jdx]; - jdx++; - ptr=ptr2; - }while(1); - } + line = file_read_line(vf); + while(!feof(vf)){ + ptr=&(line[0]); + if((*ptr=='E')&&(*(ptr+1)=='A')) { + ptr=ptr+2; + num=(gint)g_ascii_strtoull(ptr,NULL,10); + if(num>max_num_p) max_num_p=num; + fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + add_frame_offset(vf, model); + model->num_frames++; + g_free(line); + line = file_read_line(vf); } - vfpos=ftell(vf);/* flag */ - idx++; - g_free(line); - line = file_read_line(vf); - } - strcpy(model->filename,aux_file);// which means that we "forget" about OUTPUT.txt - g_free(aux_file); + g_free(line); + vfpos=ftell(vf);/* flag */ + line = file_read_line(vf); + } +/* +++ challenge the max_num_p with Individuals max_num_i*/ fclose(vf); -/* --- READ Individuals <- information about all structures */ -/* ^^^ META is ill-defined: read first Individuals, then update with Individual_relaxed and hope*/ aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); + vf = fopen(aux_file, "rt"); + if (!vf) { + line = g_strdup_printf("ERROR: can't open USPEX Individuals file!\n"); + gui_text_show(ERROR, line); + g_free(line); + g_free(aux_file); + goto uspex_fail; + } + g_free(aux_file); + num=0;max_num_i=0; + line = file_read_line(vf); + while(!feof(vf)){ + ptr=&(line[0]); + __SKIP_BLANK(ptr); + num=(gint)g_ascii_strtoull(ptr,&(ptr2),10); + if(ptr2!=NULL) { + num=0; + ptr=ptr2+1; + __SKIP_BLANK(ptr); + num=(gint)g_ascii_strtoull(ptr,NULL,10); + if(num>max_num_i) max_num_i=num; + } + g_free(line); + line = file_read_line(vf); + } + if(max_num_p idx ind*/ + fclose(vf); +/* +++ alloc/prepare the Ind array!*/ + _UO.ind=g_malloc(_UO.num_struct*sizeof(uspex_individual)); + for(idx=0;idx<_UO.num_struct;idx++) { + _UO.ind[idx].have_data=FALSE; + _UO.ind[idx].have_struct=FALSE; + _UO.ind[idx].atoms=g_malloc(_UO.calc->_nspecies*sizeof(gint)); + } + /*exept for META, _UO.ind[0] will contain no data!*/ +/* +++ load Individuals*/ + if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); + else aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); if(read_individuals_uspex(aux_file,model)!=0) { - line = g_strdup_printf("ERROR: reading USPEX Individuals file!\n"); + if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: reading USPEX Individuals_relaxed file!\n"); + else line = g_strdup_printf("ERROR: reading USPEX Individuals file!\n"); gui_text_show(ERROR, line); g_free(line); + g_free(aux_file); goto uspex_fail; } g_free(aux_file); - if(_UC.calculationMethod==US_CM_META) { - aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); - vf = fopen(aux_file, "rt"); - if (!vf) { - g_free(aux_file); - }else{ - /*we have an Individuals_relaxed, read it and update ONLY the structure defined inside*/ - vfpos=ftell(vf);/* flag */ - line = file_read_line(vf); - while(line){ - ptr=&(line[0]); - while(*ptr==' ') ptr++; - if(g_ascii_isdigit(*ptr)) { - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - break; - } - vfpos=ftell(vf);/* flag */ - g_free(line); - line = file_read_line(vf); - } - g_free(line); - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - line = file_read_line(vf); - if(line==NULL) goto no_ind_relax; - /*skip the gen=0 value!!*/ - g_free(line);line = file_read_line(vf); - vfpos=ftell(vf);/* flag */ - /*no need to count, there will be less structure*/ - line = file_read_line(vf); - while(line){ - sscanf(line," %*i %i %*s",&idx); - if(_UO.have_fitness){ -sscanf(line," %i %*i%*[^[][%*[^]]] %lf %lf %*f %lf %*s", - &(_UO.ind[idx].gen),&(_UO.ind[idx].energy),&(_UO.ind[idx].volume),&(_UO.ind[idx].fitness)); -if(isnan(_UO.ind[idx].fitness)) _UO.ind[idx].fitness=10000; - }else{ -sscanf(line," %i %*i%*[^[][%*[^]]] %lf %lf %*s", - &(_UO.ind[idx].gen),&(_UO.ind[idx].energy),&(_UO.ind[idx].volume)); + if(_UO.have_supercell){ + /*rescale natoms in case of a supercell calculation*/ + for(idx=0;idx<_UO.num_struct;idx++) _UO.ind[idx].natoms*=atom_per_supercell; + + } + n_data=0;for(idx=0;idx<_UO.num_struct;idx++) if(_UO.ind[idx].have_data) n_data++; +/* +++ get gatherPOSCARS information for have_data=FALSE (is any)*/ + if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); + else aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); + vf = fopen(aux_file, "rt"); + if (!vf) { + if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: can't re-open USPEX gatheredPOSCARS_relaxed file?!\n"); + else line = g_strdup_printf("ERROR: can't re-open USPEX gatheredPOSCARS file?!\n"); + gui_text_show(ERROR, line); + g_free(line); + g_free(aux_file); + goto uspex_fail; + } + g_free(aux_file); + idx=0; +/* +++ get atomTypes if missing from Paramters.txt <- and this is bad*/ +if(_UC.atomType==NULL){ + line = file_read_line(vf); + while((idx<5)&&(!feof(vf))){ + idx++; + g_free(line); + line = file_read_line(vf); + } + if(line){ + ptr=&(line[0]); + num=0;__COUNT_ALNUM(ptr,num); + _UC.atomType=g_malloc(num*sizeof(gint)); + ptr=&(line[0]); + for(idx=0;idx_UO.num_gen){ - _UO.graph=graph_new("ALL", model); - _UO.graph_best=graph_new("BEST", model); - _UO.num_best=_UO.num_gen;/*I hope this one is always true*/ - _UO.best_ind=g_malloc((1+_UO.num_best)*sizeof(gint)); - for(ix=0;ix<(1+_UO.num_best);ix++) _UO.best_ind[ix]=0; - /*NEW: read BESTIndividuals IDs first, when exists!*/ -if(_UO.calc->calculationMethod==US_CM_META){ - aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals_relaxed"); - vf = fopen(aux_file, "rt");g_free(aux_file); - if(!vf) { - aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals"); - vf = fopen(aux_file, "rt");g_free(aux_file); - } -}else{ - aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals"); - vf = fopen(aux_file, "rt");g_free(aux_file); -} - probe=0; -if(vf){ - /*read BESTIndividuals*/ - /*skip header, avoid _BUG_ when Individual format have 1 OR 2 line header.*/ + fclose(vf);vf=NULL; +/* +++ load BEST data*/ + if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals_relaxed"); + else aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals"); + vf = fopen(aux_file, "rt"); + if (!vf) { + if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: can't open USPEX BESTIndividuals_relaxed file!\n"); + else line = g_strdup_printf("ERROR: can't open USPEX BESTIndividuals file?!\n"); + gui_text_show(ERROR, line); + g_free(line); + g_free(aux_file); + goto uspex_fail; + } + g_free(aux_file); + /*count the number of BEST structures*/ + line = file_read_line(vf);/*TITLE LINE, DISCARD*/ + g_free(line); + vfpos=ftell(vf);/* flag */ + line = file_read_line(vf); + ptr=&(line[0]); + __SKIP_BLANK(ptr); + while(!g_ascii_isdigit(*ptr)){ + /*skip additionnal header lines*/ + g_free(line); vfpos=ftell(vf);/* flag */ line = file_read_line(vf); - while(line){ - ptr=&(line[0]); - while(*ptr==' ') ptr++; - if(g_ascii_isdigit(*ptr)) { - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - break; - } - vfpos=ftell(vf);/* flag */ - g_free(line); - line = file_read_line(vf); - } - if(line==NULL) goto no_best_ind; - /* META calculation have a gen=0 Individual - unfortunately, it is *not* in the gather- - -POSCARS file, so we ignore gen=0 for now. */ - if(_UO.calc->calculationMethod==US_CM_META){ - g_free(line); - line = file_read_line(vf); - vfpos=ftell(vf);/* flag */ - } - /*count best stuctures*/ - num=0; - while (line){ - num++; - g_free(line); - line = file_read_line(vf); + ptr=&(line[0]); + __SKIP_BLANK(ptr); + } + /*count number of lines -> num_best*/ + _UO.num_best=0; + while(line){ + _UO.num_best++; + g_free(line); + line = file_read_line(vf); + } + fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + /*prepare (NEW) best_ind array*/ + _UO.best_ind=g_malloc((2*_UO.num_best)*sizeof(gint)); + line = file_read_line(vf); + idx=0; + while(line){ + ptr=&(line[0]); + __SKIP_BLANK(ptr); + _UO.best_ind[idx]=(gint)g_ascii_strtoull(ptr,&(ptr2),10); + if(ptr2!=NULL) { + ptr=ptr2+1; + _UO.best_ind[idx+1]=(gint)g_ascii_strtoull(ptr,NULL,10); } - num--; - if(num>_UO.num_best) goto no_best_ind;/*num<_UO.num_best is allowed for unfinished calculation*/ - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + idx=idx+2; + g_free(line); line = file_read_line(vf); - /*now fill array*/ - while(line){ - sscanf(line," %i %i %*s",&gen,&ix); - ix--; - if(_UO.calc->calculationMethod==US_CM_META) ix--;/*META "special" numbering*/ - _UO.best_ind[gen]=ix; + } +/* +++ prepare ALL graph*/ + _UO.graph=graph_new("ALL", model); + /*process ALL graph ; ALL graph is _always_ enthalpy*/ + min_E=_UO.min_E-(_UO.max_E-_UO.min_E)*0.05; + max_E=_UO.max_E+(_UO.max_E-_UO.min_E)*0.05; + gen=0;iix=0; + if(!(_UC.calculationMethod==US_CM_META)) { + /*create a fake 0 generation*/ + e=g_malloc(2*sizeof(gdouble)); + e[0]=(gdouble)1; + e[1]=_UO.max_E*2.;/*out of graph ;)*/ + graph_add_borned_data(_UO.num_gen,e,0,_UO.num_gen,min_E,max_E,GRAPH_USPEX,_UO.graph); + g_free(e); + gen=1; + } + ptr=g_malloc((1+n_data)*sizeof(gchar));/*NEW: graph "color"*/ + ptr[n_data]='\0';/*valgrind fix*/ + /*in both META and non-META case, frame_0 does not exists _BUT_ META have data for it*/ + if(_UC.calculationMethod==US_CM_META) _UO.ind[1].have_struct=FALSE;jdx=0; + /*calculate color here*/ + for(idx=0;idx<_UO.num_struct;idx++){ + if(_UO.ind[idx].have_data){ + if(_UO.ind[idx].have_struct) ptr[jdx]='O'; + else ptr[jdx]='X'; + jdx++; + } + } + idx=0; + while(gen<=_UO.num_gen){ + /*prepare one generation*/ + jdx=idx;num=0;isok=TRUE;//(_UO.ind[jdx].gen<=gen); + while(isok) { + if(_UO.ind[jdx].have_data) num++; + jdx++; + isok=(jdx<_UO.num_struct); + if(isok) isok&=(_UO.ind[jdx].gen<=gen); + } #if DEBUG_USPEX_READ - fprintf(stdout,"#DBG: USPEX GEN=%i BESTIndividuals=%i E=%f f=%f\n", - gen,ix+1,_UO.ind[_UO.best_ind[gen]].energy,_UO.ind[_UO.best_ind[gen]].fitness); +fprintf(stdout,"#DBG graph_all: GEN=%i num=%i ",gen,num); #endif - g_free(line); - line = file_read_line(vf); + e=g_malloc((1+num)*sizeof(gdouble)); + e[0]=(gdouble)num; + jdx=idx;ix=1;isok=TRUE;//(_UO.ind[jdx].gen<=gen); + while(isok) { + if(_UO.ind[jdx].have_data){ + e[ix]=_UO.ind[jdx].E; +#if DEBUG_USPEX_READ +fprintf(stdout,"E[%i]=e[%i]=%lf c[%i]=%c ",jdx,ix,e[ix],iix,ptr[iix]); +#endif + iix++; + ix++; + } + jdx++; + isok=(jdx<_UO.num_struct); + if(isok) isok&=(_UO.ind[jdx].gen<=gen); } - /*that's all <- we get values directly from Individuals*/ - probe=1; -no_best_ind: - fclose(vf); -} - skip=0; - gen=1; - ix=0; - while(gen<=_UO.num_gen){ - while(_UO.ind[ix].gen max_E) max_E=_UO.ind[_UO.best_ind[2*idx+1]].fitness; }else{ - if(_UO.ind[ix].E max_E) max_E=_UO.ind[_UO.best_ind[2*idx+1]].E; } + }else{ + ptr[idx]='X';/*ie. cross*/ + } + } + /*for case where fitness is not properly calculated*/ + if(max_E==min_E) { + min_E-=0.1; + max_E+=0.1; + } + /*process BEST graph ; NEW: fitness or enthalpy*/ + min_E=min_E-(max_E-min_E)*0.05; + max_E=max_E+(max_E-min_E)*0.05; + gen=0; + if(!(_UC.calculationMethod==US_CM_META)) { + /*create a fake 0 generation*/ + e=g_malloc(2*sizeof(gdouble)); + e[0]=(gdouble)1; + e[1]=max_E*2.;/*out of graph ;)*/ + graph_add_borned_data(_UO.num_gen,e,0,_UO.num_gen,min_E,max_E,GRAPH_USPEX,_UO.graph_best); + g_free(e); + gen=1; + } + idx=0; + while(gen<=_UO.num_gen){ + jdx=idx;num=0;isok=TRUE;//(_UO.best_ind[jdx]<=gen); + while(isok) { num++; - ix++; - if(ix>=_UO.num_struct) break;/*FIX _VALGRIND_BUG_*/ - } -}else{ - min_E=_UO.ind[_UO.best_ind[gen]].E; - if(_UO.have_fitness) min_F=_UO.ind[_UO.best_ind[gen]].fitness; - while(_UO.ind[ix].gen==gen){ - num++; - ix++; - if(ix>=_UO.num_struct) break; - } -} - e=g_malloc((1+num)*sizeof(gdouble)); - ix=skip; - e[0]=(gdouble)num; - while(_UO.ind[ix].gen==gen){ - e[ix-skip+1]=_UO.ind[ix].E; - ix++; - if(ix>=_UO.num_struct) break;/*FIX _VALGRIND_BUG_*/ - } - graph_add_borned_data( - _UO.num_gen,e,0,_UO.num_gen, - _UO.min_E-(_UO.max_E-_UO.min_E)*0.05,_UO.max_E+(_UO.max_E-_UO.min_E)*0.05,GRAPH_USPEX,_UO.graph); - gen++; - g_free(e); + jdx+=2;/*interleave data!*/ + isok=(jdx<2*_UO.num_best); + if(isok) isok&=(_UO.best_ind[jdx]<=gen); } - /*prepare array*/ - e=g_malloc((1+_UO.num_gen)*sizeof(gdouble)); - e[0]=(gdouble)_UO.num_gen; - max_E=_UO.ind[_UO.best_ind[1]].E; - min_E=max_E; - for(gen=0;gen<_UO.num_gen;gen++) { - e[gen+1]=_UO.ind[_UO.best_ind[gen+1]].E; - if(max_Ee[gen+1]) min_E=e[gen+1]; #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX_BEST: GEN=%i STRUCT=%i E=%lf e=%f\n",gen+1,1+_UO.best_ind[gen+1],e[gen+1],_UO.ind[_UO.best_ind[gen+1]].energy); +fprintf(stdout,"#DBG graph_best: num=%i ",num); #endif + e=g_malloc((1+num)*sizeof(gdouble)); + e[0]=(gdouble)num; + jdx=idx;ix=1;isok=TRUE;//(_UO.best_ind[jdx]<=gen); + while(isok) { + if(_UO.have_fitness){ + e[ix]=_UO.ind[_UO.best_ind[jdx+1]].fitness; + }else{ + e[ix]=_UO.ind[_UO.best_ind[jdx+1]].E; + } +#if DEBUG_USPEX_READ +fprintf(stdout,"e[%i]=%lf ",ix,e[ix]); +#endif + + ix++; + jdx+=2; + isok=(jdx<2*_UO.num_best); + if(isok) isok&=(_UO.best_ind[jdx]<=gen); } - if(max_E==min_E) { - min_E-=0.1; - max_E+=0.1; - } - graph_add_borned_data( - _UO.num_gen,e,0,_UO.num_gen, - min_E-(max_E-min_E)*0.05,max_E+(max_E-min_E)*0.05,GRAPH_USPEX_BEST,_UO.graph_best); +#if DEBUG_USPEX_READ +fprintf(stdout,"-SENT\n"); +#endif + graph_add_borned_data(_UO.num_gen,e,0,_UO.num_gen,min_E,max_E,GRAPH_USPEX,_UO.graph_best); g_free(e); + /*to next gen*/ + idx=jdx; + gen++; } + graph_set_color(ptr,_UO.graph_best); + g_free(ptr); /*set ticks*/ if(_UO.num_gen>15) ix=5; else ix=_UO.num_gen+1; @@ -2703,117 +2857,71 @@ fprintf(stdout,"#DBG: USPEX_BEST: GEN=%i STRUCT=%i E=%lf e=%f\n",gen+1,1+_UO.bes graph_set_xticks(TRUE,ix,_UO.graph_best); graph_set_yticks(TRUE,5,_UO.graph_best); /* --- variable composition */ -if(_UO.var){ -/* --- NEW: add a simple composition % graph for each species */ -if(_UC._nspecies>1){ -n_compo=2; -ix=0; -for(species_index=0;species_index<_UC._nspecies;species_index++){ - c=g_malloc(2*sizeof(gdouble));/*suppose at least 2 different compositions*/ - c[0]=(gdouble)_UO.ind[0].atoms[species_index] / (gdouble)_UO.ind[0].natoms; - c[1]=c[0]; - compo=c[0]; - ix=0; - while((compo==c[0])&&(ix<_UO.num_struct)){ - compo=(gdouble)_UO.ind[ix].atoms[species_index] / (gdouble)_UO.ind[ix].natoms; - if(compo!=c[0]){ - if(compo>c[0]) c[1]=compo; - else { - c[1]=c[0];c[0]=compo; - } - } - ix++; - } - if(c[1]==c[0]) continue;/*in VARCOMP calculation, one species can be kept fixed*/ - for(ix=0;ix<_UO.num_struct;ix++){ - compo=(gdouble)_UO.ind[ix].atoms[species_index] / (gdouble)_UO.ind[ix].natoms; - if(compoc[n_compo-1]){/*we have a new last element*/ - tmp=g_malloc((n_compo+1)*sizeof(gdouble)); - tmp[n_compo]=compo; - memcpy(&(tmp[0]),c,n_compo*sizeof(gdouble)); - g_free(c); - c=tmp; - n_compo++; - continue; - } - for(jdx=1;jdxc[jdx-1])&&(compo_calctype_var)&&(_UC._nspecies>1)){ + /*calculate n_compo*/ + n_compo=n_data; + _UO.graph_comp=g_malloc(_UC._nspecies*sizeof(gpointer)); + for(species_index=0;species_index<_UC._nspecies;species_index++){ + /*one COMP graph per species*/ tag=g_malloc(n_compo*sizeof(gdouble)); - max_E=_UO.min_E; - for(ix=0;ixmax_E) max_E=e[jdx]; - } - } - } + c=g_malloc(n_compo*sizeof(gdouble)); + e=g_malloc(n_compo*sizeof(gdouble)); + ptr=g_malloc(1+n_compo*sizeof(gchar));/*NEW: graph "color"*/ + ptr[n_compo]='\0';/*\0 termination for valgrind*/ + jdx=0; + /*initialize with 1 to avoid gen=0 trouble*/ + c_sum=0;for(ix=0;ix<_UO.calc->_nspecies;ix++) c_sum+=_UO.ind[1].atoms[ix]; +/* +++ calculate all compositions*/ + for(idx=0;idx<_UO.num_struct;idx++){ + if(!_UO.ind[idx].have_data) continue; + if(_UO.ind[idx].have_struct) ptr[jdx]='O';/*ie. square*/ + else ptr[jdx]='X';/*ie. cross*/ + tag[jdx]=(gdouble)idx; + c_sum=0;for(ix=0;ix<_UO.calc->_nspecies;ix++) c_sum+=_UO.ind[idx].atoms[ix]; + c[jdx]=(gdouble)(_UO.ind[idx].atoms[species_index])/c_sum; + e[jdx]=_UO.ind[idx].E; +#if DEBUG_USPEX_READ +fprintf(stdout,"#DBG graph_comp: num=%i compo[%i]=%lf E[%i]=e[%i]=%lf c=%c",n_compo,jdx,c[jdx],idx,jdx,e[jdx],ptr[jdx]); +#endif + jdx++; } - /* prepare composition diagram*/ + /*TODO: calculate convex hull: B color, line set*/ line=g_strdup_printf("COMP_%s",elements[_UC.atomType[species_index]].symbol); - _UO.graph_comp=graph_new(line, model); - graph_add_borned_data( - n_compo,tag,0,1,_UO.min_E-(max_E-_UO.min_E)*0.05,max_E+(max_E-_UO.min_E)*0.05,GRAPH_USPEX_2D,_UO.graph_comp); - graph_add_borned_data( - n_compo,c,0,1,_UO.min_E-(max_E-_UO.min_E)*0.05,max_E+(max_E-_UO.min_E)*0.05,GRAPH_USPEX_2D,_UO.graph_comp); - graph_add_borned_data( - n_compo,e,0,1,_UO.min_E-(max_E-_UO.min_E)*0.05,max_E+(max_E-_UO.min_E)*0.05,GRAPH_USPEX_2D,_UO.graph_comp); - g_free(line); + _UO.graph_comp[species_index]=graph_new(line, model); +/* +++ send graph data*/ + min_E=_UO.min_E-(_UO.max_E-_UO.min_E)*0.05; + max_E=_UO.max_E+(_UO.max_E-_UO.min_E)*0.05; +#if DEBUG_USPEX_READ +fprintf(stdout,"-SENT\n"); +#endif + graph_add_borned_data(n_compo,tag,0,1,min_E,max_E,GRAPH_USPEX_2D,_UO.graph_comp[species_index]); + graph_add_borned_data(n_compo,c,0,1,min_E,max_E,GRAPH_USPEX_2D,_UO.graph_comp[species_index]); + graph_add_borned_data(n_compo,e,0,1,min_E,max_E,GRAPH_USPEX_2D,_UO.graph_comp[species_index]); + graph_set_color(ptr,_UO.graph_comp[species_index]); + g_free(line); + g_free(ptr); g_free(tag); g_free(c); g_free(e); - /*set ticks*/ - graph_set_xticks(TRUE,3,_UO.graph_comp); - graph_set_yticks(TRUE,5,_UO.graph_comp); - + /*set ticks*/ + graph_set_xticks(TRUE,3,_UO.graph_comp[species_index]); + graph_set_yticks(TRUE,5,_UO.graph_comp[species_index]); } - -}/*variable composition with only 1 species...*/ -}/*not a VARCOMP calculation*/ - +}/* ^^^ end variable composition*/ /*refresh model*/ tree_model_refresh(model); - model->redraw = TRUE; - /* always show this information */ - gui_text_show(ITALIC,g_strdup_printf("USPEX: %i structures detected.\n",model->num_frames)); - model_prep(model); - - -}else if(_UC.calculationMethod==US_CM_VCNEB){ -/* --- tentative at adding VCNEB, which format is different**/ -/* ^^^ *BUT unfortunately, we NEED a vasp5 output (VCNEB stayed at VASP4) */ -/* thus we create a new file called transitionPath_POSCARs5 which is a - * translation of transitionPath_POSCARs for VASP5...*/ + model->redraw = TRUE; + /* always show this information */ + line=g_strdup_printf("USPEX: %i structures detected.\n",model->num_frames); + gui_text_show(ITALIC,line); + g_free(line); + model_prep(model); +}/* ^^^ end ANYTHING but VCNEB, and TPS*/ +/* --- VCNEB method*/ +else if(_UC.calculationMethod==US_CM_VCNEB){ +/* +++ transitionPath_POSCARs conversion to VASP5 format*/ +if(_UO.version<1010){ atoms = g_strdup_printf("%s",elements[_UC.atomType[0]].symbol); for(idx=1;idx<_UC._nspecies;idx++){ line = g_strdup_printf("%s %s",atoms,elements[_UC.atomType[idx]].symbol); @@ -2827,6 +2935,7 @@ for(species_index=0;species_index<_UC._nspecies;species_index++){ line = g_strdup_printf("ERROR: can't open USPEX transitionPath_POSCARs file!\n"); gui_text_show(ERROR, line); g_free(line); + g_free(aux_file); goto uspex_fail; } g_free(aux_file); @@ -2836,8 +2945,10 @@ for(species_index=0;species_index<_UC._nspecies;species_index++){ line = g_strdup_printf("ERROR: can't WRITE into USPEX transitionPath_POSCARs5 file!\n"); gui_text_show(ERROR, line); g_free(line); + g_free(aux_file); goto uspex_fail; } + g_free(aux_file); /*get the total number of atoms*/ for(idx=0;idx<5;idx++){ line = file_read_line(f_src); @@ -2872,9 +2983,31 @@ fprintf(stdout,"#DBG: USPEX[VCNEB]: NATOMS=%i ATOMS=%s\n",natoms,atoms); fclose(f_src); fclose(f_dest); g_free(atoms); - _UO.ind=g_malloc((_UO.num_struct)*sizeof(uspex_individual)); -/* --- read energies from the Energy file */ +}/* ^^^ end transitionPath_POSCARs conversion*/ +/* +++ VER 10.1 create a VASP5 format transitionPath_POSCARs!*/ +else{ + /*read the number of structures*/ + aux_file = g_strdup_printf("%s%s",res_folder,"transitionPath_POSCARs"); + vf = fopen(aux_file, "rt"); + if(!vf){ + line = g_strdup_printf("ERROR: can't open USPEX transitionPath_POSCARs file!\n"); + gui_text_show(ERROR, line); + g_free(line); + g_free(aux_file); + goto uspex_fail; + } g_free(aux_file); + _UO.num_struct=0; + line = file_read_line(vf); + while(line){ + if (find_in_string("Image",line) != NULL) _UO.num_struct++; + g_free(line); + line = file_read_line(vf); + } + fclose(vf); +} +/* --- read energies from the Energy file */ + _UO.ind=g_malloc((_UO.num_struct)*sizeof(uspex_individual)); aux_file = g_strdup_printf("%s%s",res_folder,"Energy"); vf=fopen(aux_file,"rt"); if (!vf) { @@ -2921,17 +3054,18 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i } fclose(vf);vf=NULL; g_free(aux_file); - /*create the reduced index table*/ - _UO.red_index=g_malloc(_UO.num_struct*sizeof(gint)); - for(idx=0;idx<_UO.num_struct;idx++) _UO.red_index[idx]=idx; - aux_file = g_strdup_printf("%s%s",res_folder,"transitionPath_POSCARs5"); -/* --- reopen the newly created transitionPath_POSCARs5 file for reading <- this will be our new model file*/ +/* --- reopen transitionPath_POSCARs or the newly created transitionPath_POSCARs5 file for reading + * ^^^ this will be our new model file*/ + if(_UO.version<1010) aux_file = g_strdup_printf("%s%s",res_folder,"transitionPath_POSCARs5"); + else aux_file = g_strdup_printf("%s%s",res_folder,"transitionPath_POSCARs"); vf=fopen(aux_file,"rt"); if (!vf) {/*very unlikely: we just create it*/ g_free(_UO.ind); - line = g_strdup_printf("ERROR: can't open USPEX transitionPath_POSCARs5 file!\n"); + if(_UO.version<1010) line = g_strdup_printf("ERROR: can't open USPEX transitionPath_POSCARs5 file!\n"); + else line = g_strdup_printf("ERROR: can't open USPEX transitionPath_POSCARs file!\n"); gui_text_show(ERROR, line); g_free(line); + g_free(aux_file); goto uspex_fail; } model->num_frames=0; @@ -2957,7 +3091,6 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i rewind(vf); read_frame_uspex(vf,model);/*open first frame*/ fclose(vf);vf=NULL; - /*do a "best" graph with each image*/ _UO.graph_best=graph_new("PATH", model); _UO.num_gen=_UO.num_struct; @@ -2970,19 +3103,15 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i else ix=_UO.num_gen+1; graph_set_xticks(TRUE,ix,_UO.graph_best); graph_set_yticks(TRUE,5,_UO.graph_best); - - /*refresh model*/ tree_model_refresh(model); model->redraw = TRUE; /* always show this information */ gui_text_show(ITALIC,g_strdup_printf("USPEX: %i structures detected.\n",model->num_frames)); model_prep(model); - - - -}else{/*calculation method is not supported*/ - line = g_strdup_printf("ERROR: USPEX support is limited to calculationMethod={USPEX,META,VCNEB} for now!\n"); +}/* ^^^ end VCNEB method*/ +else{/*calculation method is not supported*/ + line = g_strdup_printf("ERROR: USPEX unsupport method!\n"); gui_text_show(ERROR, line); g_free(line); goto uspex_fail; @@ -3001,6 +3130,9 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i g_free(line); return 3; } +/********************/ +/* read_frame_uspex */ +/********************/ gint read_frame_uspex(FILE *vf, struct model_pak *model){ gchar *line; uspex_output_struct *uspex_output=model->uspex; @@ -3020,11 +3152,10 @@ sscanf(ptr,"%i%*s",&idx); g_free(line);/*FIX: _VALGRIND_BUG_*/ fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ if(vasp_load_poscar5(vf,model)<0) return 3; -/* in case of meta idx is *not* the real number of the structure */ -/* now the index should always be _UO.red_index[idx-1] <- I THINK*/ - line=g_strdup_printf("%lf eV",_UO.ind[_UO.red_index[idx-1]].energy); +if(_UO.ind[idx].have_data){ + line=g_strdup_printf("%lf eV",_UO.ind[idx].energy); property_add_ranked(3, "Energy", line, model); - model->volume=_UO.ind[_UO.red_index[idx-1]].volume; + model->volume=_UO.ind[idx].volume; g_free(line);line=g_strdup_printf("%lf uV",model->volume); property_add_ranked(4, "Volume", line, model); g_free(line); @@ -3032,10 +3163,11 @@ fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ line=g_strdup_printf("%i",idx); property_add_ranked(8, "Structure", line, model); g_free(line); -if(_UO.have_fitness){ - line=g_strdup_printf("%f f",_UO.ind[_UO.red_index[idx-1]].fitness); - property_add_ranked(9, "Fitness", line, model); - g_free(line); + if(_UO.have_fitness){ + line=g_strdup_printf("%f f",_UO.ind[idx].fitness); + property_add_ranked(9, "Fitness", line, model); + g_free(line); + } } return 0; } diff --git a/src/file_uspex.h b/src/file_uspex.h index 902e66d..302b723 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -90,13 +90,17 @@ typedef enum { US_BT_UNKNOWN=-1, /*invalid entry*/ } uspex_bt_goal; typedef struct { + gboolean have_data; /*NEW: allow incomplete Individuals*/ + gboolean have_struct; /*NEW: allow incomplete gatheredPOSCARS*/ gint gen; /*generation of this individual*/ gint natoms; /*number of atoms*/ gint *atoms; /*number of atoms per species*/ gdouble energy; /*total energy*/ gdouble E; /*reduce energy / atoms*/ - gdouble fitness; /*NEW: fitness*/ + gdouble fitness; /*fitness*/ gdouble volume; /*total volume*/ + gdouble density; /*NEW: density*/ + gint symmetry; /*NEW: Symmetry*/ } uspex_individual; /* USPEX calculation structure */ typedef struct { @@ -294,25 +298,23 @@ typedef struct { gint version; gint index; /*index is the # of result folder*/ uspex_calc_struct *calc; - /* details */ - gint dim; - gboolean mol; - gboolean var; /* optimization */ + gboolean have_supercell; /*NEW: deal with supecell automagic*/ gboolean have_fitness; /*structures*/ gint num_gen; gint num_struct; - gint *red_index; /*in case not all structure are displayed (ie. META)*/ gdouble min_E; gdouble max_E; + gdouble min_F; /*NEW: fitness data*/ + gdouble max_F; /*NEW: fitness data*/ uspex_individual *ind; gint num_best; - gint *best_ind; + gint *best_ind; /*NEW: {ID - GEN} there can be several best in a generation*/ /*interpretation*/ gpointer graph; gpointer graph_best; - gpointer graph_comp; + gpointer *graph_comp; } uspex_output_struct; /* execution structure */ typedef struct { diff --git a/src/gl_graph.c b/src/gl_graph.c index 70c3045..522ebbe 100644 --- a/src/gl_graph.c +++ b/src/gl_graph.c @@ -120,6 +120,7 @@ graph->ymax = 0.0; graph->xticks = 5; graph->yticks = 5; graph->size = 0; +graph->color = NULL; graph->select = -1; graph->select_label = NULL; graph->set_list = NULL; @@ -205,7 +206,9 @@ g_assert(graph != NULL); graph->wavelength = wavelength; } - +/********************************/ +/* regular selection of 1D data */ +/********************************/ void graph_set_select(gdouble x, gchar *label, gpointer data) { gdouble n; @@ -232,7 +235,6 @@ else printf("select -> %d : [0, %d]\n", graph->select, graph->size); */ } - /*****************************/ /* add dependent data set(s) */ /*****************************/ @@ -260,7 +262,6 @@ graph_init_y(x, graph); graph->set_list = g_slist_append(graph->set_list, ptr); } - /*********************************/ /* add borned (x,y) data (ovhpa) */ /*********************************/ @@ -309,6 +310,14 @@ graph->type=type; graph->set_list = g_slist_append(graph->set_list, ptr); } +/**************************/ +/* set graph data "color" */ +/**************************/ +void graph_set_color(gchar *color,gpointer data){ + struct graph_pak *graph = data; + if(graph->color!=NULL) g_free(graph->color); + graph->color=g_strdup(color); +} /*********************************************/ /* select a value in a GRAPH_FREQUENCY graph */ /*********************************************/ @@ -413,7 +422,7 @@ if((y>yy-3)&&(yset_list ; list ; list=g_slist_next(list)) { if(j>struct_sel) return; @@ -570,6 +579,7 @@ void graph_draw_new(struct canvas_pak *canvas, struct graph_pak *graph){ gint i, j, x, y, oldx, oldy, ox, oy, sx, sy; gint flag; gchar *text; +gchar *color=&(graph->color[0]); gdouble *ptr; gdouble xf, yf, dx, dy; GSList *list; @@ -957,7 +967,7 @@ switch (graph->type){ break; case GRAPH_USPEX_BEST: case GRAPH_USPEX: - xf += 1.; +// xf += 1.; xf /= (gdouble) (graph->size);/*NOT size*/ x = ox + xf*dx; yf -= graph->ymin; @@ -966,6 +976,8 @@ switch (graph->type){ y = (gint) yf; y *= -1; y += oy; +if(color!=NULL){ + if(*color=='O'){ /*draw a rectangle*/ glBegin(GL_LINE_STRIP); gl_vertex_window(x-2, y-2, canvas); @@ -974,6 +986,29 @@ switch (graph->type){ gl_vertex_window(x-2, y+2, canvas); gl_vertex_window(x-2, y-2, canvas); glEnd(); + color++; + }else if(*color=='X'){ + /*draw a cross*/ + glBegin(GL_LINE_STRIP); + gl_vertex_window(x-2, y-2, canvas); + gl_vertex_window(x+2, y+2, canvas); + glEnd(); + glBegin(GL_LINE_STRIP); + gl_vertex_window(x+2, y-2, canvas); + gl_vertex_window(x-2, y+2, canvas); + glEnd(); + color++; + } +}else{ + /*draw a default rectangle*/ + glBegin(GL_LINE_STRIP); + gl_vertex_window(x-2, y-2, canvas); + gl_vertex_window(x+2, y-2, canvas); + gl_vertex_window(x+2, y+2, canvas); + gl_vertex_window(x-2, y+2, canvas); + gl_vertex_window(x-2, y-2, canvas); + glEnd(); +} break; case GRAPH_USPEX_2D: xf -= graph->xmin; @@ -985,6 +1020,8 @@ switch (graph->type){ y = (gint) yf; y *= -1; y += oy; +if(color!=NULL){ + if(*color=='O'){ /*draw a rectangle*/ glBegin(GL_LINE_STRIP); gl_vertex_window(x-2, y-2, canvas); @@ -993,6 +1030,29 @@ switch (graph->type){ gl_vertex_window(x-2, y+2, canvas); gl_vertex_window(x-2, y-2, canvas); glEnd(); + color++; + }else if(*color=='X'){ + /*draw a cross*/ + glBegin(GL_LINE_STRIP); + gl_vertex_window(x-2, y-2, canvas); + gl_vertex_window(x+2, y+2, canvas); + glEnd(); + glBegin(GL_LINE_STRIP); + gl_vertex_window(x+2, y-2, canvas); + gl_vertex_window(x-2, y+2, canvas); + glEnd(); + color++; + } +}else{ + /*draw a default rectangle*/ + glBegin(GL_LINE_STRIP); + gl_vertex_window(x-2, y-2, canvas); + gl_vertex_window(x+2, y-2, canvas); + gl_vertex_window(x+2, y+2, canvas); + gl_vertex_window(x-2, y+2, canvas); + gl_vertex_window(x-2, y-2, canvas); + glEnd(); +} if((i == graph->select)&&(ptr[i] == graph->select_2)){ sx=x; sy=y-1; @@ -1117,7 +1177,7 @@ switch (graph->type){ glEnd(); break; case GRAPH_USPEX_BEST: - case GRAPH_USPEX_2D:/*TODO: add a 0.5 composition axis?*/ + case GRAPH_USPEX_2D: case GRAPH_USPEX: case GRAPH_FREQUENCY: case GRAPH_REGULAR: diff --git a/src/graph.h b/src/graph.h index 985d177..453e4dc 100644 --- a/src/graph.h +++ b/src/graph.h @@ -54,6 +54,7 @@ struct graph_pak gdouble ymax; /* NB: all sets are required to be <= size */ gint size; + gchar *color;/*size array of "color"*/ GSList *set_list;/*in case of 1D graph, set_list={x[,tag]} for 2D set_list={x,y[,tag]}*/ /* peak selection */ gint select; @@ -63,6 +64,7 @@ struct graph_pak gpointer graph_new(const gchar *, struct model_pak *); void graph_free_list(struct model_pak *); void graph_free(gpointer, struct model_pak *); +void graph_set_color(gchar *color,gpointer data); void graph_add_data(gint, gdouble *, gdouble, gdouble, gpointer); void graph_add_borned_data(gint size,gdouble *x,gdouble x_min,gdouble x_max,gdouble y_min,gdouble y_max,gint type,gpointer data); void graph_frequency_select(gint x, gint y, struct model_pak *model); diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 73893b0..9f1f53b 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -371,7 +371,7 @@ void uspex_type_selected(GUI_OBJ *w){ uspex_gui.calc._calctype_var=TRUE; break; case 8://-200 - uspex_gui.calc.calculationType=US_CT_M200; + uspex_gui.calc.calculationType=US_CT_m200; uspex_gui.calc._calctype_dim=-2; uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=FALSE; @@ -442,7 +442,7 @@ void _update_calculationType(){ GUI_COMBOBOX_SET(uspex_gui.calculationType,6);break; case US_CT_201: GUI_COMBOBOX_SET(uspex_gui.calculationType,7);break; - case US_CT_M200: + case US_CT_m200: GUI_COMBOBOX_SET(uspex_gui.calculationType,8);break; case US_CT_300: default: From 5097a3136fef502221864a8f0180951ca27e495c Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 2 Nov 2018 17:14:49 +0900 Subject: [PATCH 36/56] file_uspex: update to USPEX version 10.1 (VI) + massive changes to file_uspex (2/2) + NEW graph system (symbols, line types, ...) --- src/file.h | 3 + src/file_uspex.c | 708 +++++++++++++++++++++++++++++++------------- src/file_uspex.h | 2 +- src/gl_graph.c | 757 ++++++++++++++++++++++++++--------------------- src/graph.h | 65 +++- src/gui_main.c | 3 +- src/pak.h | 2 +- 7 files changed, 973 insertions(+), 567 deletions(-) diff --git a/src/file.h b/src/file.h index 6b921e0..3def66f 100644 --- a/src/file.h +++ b/src/file.h @@ -175,6 +175,9 @@ gint read_xyz_frame(FILE *, struct model_pak *); gint read_dlpoly_frame(FILE *, struct model_pak *); gint read_dmol_frame(FILE *, struct model_pak *); +/*NEW: track/update frames (TODO)*/ +gint update_frame_uspex(gint idx,struct model_pak *model); + gint load_planes(gchar *, struct model_pak *); gint mark_trj_frames(struct model_pak *); diff --git a/src/file_uspex.c b/src/file_uspex.c index 9151ce0..344886a 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -2100,7 +2100,7 @@ gint read_individuals_uspex(gchar *filename, struct model_pak *model){ vf = fopen(filename, "rt"); if (!vf) return -1;/*fail*/ line = file_read_line(vf); - _UO.have_fitness=FALSE; +// _UO.have_fitness=FALSE; _UO.have_supercell=FALSE; // if(find_in_string("Fitness",line) != NULL) _UO.have_fitness=TRUE; if(find_in_string("SuperCell",line) !=NULL){ @@ -2178,14 +2178,14 @@ fprintf(stdout,"] natm=%i ",_UO.ind[idx].natoms); __SKIP_BLANK(ptr); }else{ /*supercell automagic*/ - ptr=ptr2+1; + ptr=ptr2+1;jdx=1; while((*ptr!=']')&&(*ptr!='\0')){ __SKIP_BLANK(ptr); - jdx+=(gint)g_ascii_strtoull(ptr,&ptr2,10); + jdx*=(gint)g_ascii_strtoull(ptr,&ptr2,10); ptr=ptr2+1; __SKIP_BLANK(ptr); } - _UO.ind[idx].natoms=jdx;/*temporary*/ + _UO.ind[idx].natoms=(gdouble)jdx;/*temporary*/ #if DEBUG_USPEX_READ fprintf(stdout," x%i ] ",_UO.ind[idx].natoms); #endif @@ -2271,28 +2271,31 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ gchar *ptr2; gchar *res_folder; gchar *aux_file; - gint ix,iix; + gint ix; gint idx; gint jdx; gint min,max,med; uspex_method method; gint nspecies; gint num; - gint atom_per_supercell; + gint *atom_n; gint max_num_p; gint max_num_i; gint n_data; /*graph*/ - gboolean isok;/*FIX valgrind _BUG_*/ gint gen; - gdouble *e; gdouble min_E; gdouble max_E; - /*compo*/ + g_data_x gx; + g_data_y gy; + /*VARCOMP*/ gint n_compo; + gdouble compo; gint c_sum; gdouble *c; - gdouble *tag; + gdouble *c_min; + gint32 *c_idx; + graph_symbol *c_sym; gint species_index; /* results */ FILE *f_src; @@ -2451,11 +2454,12 @@ if((_UC.calculationMethod==US_CM_USPEX) ||(_UC.calculationMethod==US_CM_PSO) ||(_UC.calculationMethod==US_CM_MINHOP)){ /* +++ check gatheredPOSCARS*/ - if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); else aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); vf = fopen(aux_file, "rt"); if (!vf) { - if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS_relaxed file!\n"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS_relaxed file!\n"); else line = g_strdup_printf("ERROR: can't open USPEX gatheredPOSCARS file!\n"); gui_text_show(ERROR, line); g_free(line); @@ -2483,12 +2487,19 @@ if((_UC.calculationMethod==US_CM_USPEX) g_free(line); line = file_read_line(vf); } - atom_per_supercell=0; +// atom_per_supercell=0; ptr=&(line[0]); + atom_n=g_malloc(_UO.calc->_nspecies*sizeof(gint)); + natoms=0; + jdx=0; while((*ptr!='\0')&&(*ptr!='\n')){ __SKIP_BLANK(ptr); - atom_per_supercell+=(gint)g_ascii_strtoull(ptr,&ptr2,10); + /*we also need a ratio for supercell calculations*/ + atom_n[jdx]=(gint)g_ascii_strtoull(ptr,&ptr2,10); + natoms+=atom_n[jdx]; +// atom_per_supercell+=; ptr=ptr2+1; + jdx++; } /*all done*/ num=0; @@ -2546,15 +2557,25 @@ if((_UC.calculationMethod==US_CM_USPEX) _UO.ind=g_malloc(_UO.num_struct*sizeof(uspex_individual)); for(idx=0;idx<_UO.num_struct;idx++) { _UO.ind[idx].have_data=FALSE; - _UO.ind[idx].have_struct=FALSE; + _UO.ind[idx].struct_number=-1; + _UO.ind[idx].gen=0; + _UO.ind[idx].natoms=0; _UO.ind[idx].atoms=g_malloc(_UO.calc->_nspecies*sizeof(gint)); + _UO.ind[idx].energy=0.; + _UO.ind[idx].E=0.; + _UO.ind[idx].fitness=0.; + _UO.ind[idx].volume=0.; + _UO.ind[idx].density=0.; + _UO.ind[idx].symmetry=0; } /*exept for META, _UO.ind[0] will contain no data!*/ /* +++ load Individuals*/ - if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); else aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); if(read_individuals_uspex(aux_file,model)!=0) { - if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: reading USPEX Individuals_relaxed file!\n"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + line = g_strdup_printf("ERROR: reading USPEX Individuals_relaxed file!\n"); else line = g_strdup_printf("ERROR: reading USPEX Individuals file!\n"); gui_text_show(ERROR, line); g_free(line); @@ -2563,17 +2584,22 @@ if((_UC.calculationMethod==US_CM_USPEX) } g_free(aux_file); if(_UO.have_supercell){ - /*rescale natoms in case of a supercell calculation*/ - for(idx=0;idx<_UO.num_struct;idx++) _UO.ind[idx].natoms*=atom_per_supercell; - + /*rescale atoms,natoms in case of a supercell calculation NOTE: first supercell has to be [1,1,1]*/ + for(idx=0;idx<_UO.num_struct;idx++) { + for(jdx=0;jdx<_UO.calc->_nspecies;jdx++) _UO.ind[idx].atoms[jdx]=atom_n[jdx]*_UO.ind[idx].natoms; + _UO.ind[idx].natoms*=natoms; + } } + g_free(atom_n); n_data=0;for(idx=0;idx<_UO.num_struct;idx++) if(_UO.ind[idx].have_data) n_data++; /* +++ get gatherPOSCARS information for have_data=FALSE (is any)*/ - if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); else aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); vf = fopen(aux_file, "rt"); if (!vf) { - if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: can't re-open USPEX gatheredPOSCARS_relaxed file?!\n"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + line = g_strdup_printf("ERROR: can't re-open USPEX gatheredPOSCARS_relaxed file?!\n"); else line = g_strdup_printf("ERROR: can't re-open USPEX gatheredPOSCARS file?!\n"); gui_text_show(ERROR, line); g_free(line); @@ -2619,7 +2645,7 @@ if(_UC.atomType==NULL){ idx++; ptr=ptr+2; num=(gint)g_ascii_strtoull(ptr,NULL,10); - _UO.ind[num].have_struct=TRUE; + _UO.ind[num].struct_number=idx; if(_UO.ind[num].have_data==FALSE){ /*we can't complete all data, but we can compute natoms,volume TODO*/ } @@ -2629,11 +2655,13 @@ if(_UC.atomType==NULL){ } fclose(vf); /* +++ open the structures' first frame*/ - if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS_relaxed"); else aux_file = g_strdup_printf("%s%s",res_folder,"gatheredPOSCARS"); vf = fopen(aux_file, "rt"); if (!vf) { - if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: can't re-open USPEX gatheredPOSCARS_relaxed file?!\n"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + line = g_strdup_printf("ERROR: can't re-open USPEX gatheredPOSCARS_relaxed file?!\n"); else line = g_strdup_printf("ERROR: can't re-open USPEX gatheredPOSCARS file?!\n"); gui_text_show(ERROR, line); g_free(line); @@ -2644,11 +2672,13 @@ if(_UC.atomType==NULL){ read_frame_uspex(vf,model);/*open first frame*/ fclose(vf);vf=NULL; /* +++ load BEST data*/ - if(_UC.calculationMethod==US_CM_META) aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals_relaxed"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals_relaxed"); else aux_file = g_strdup_printf("%s%s",res_folder,"BESTIndividuals"); vf = fopen(aux_file, "rt"); if (!vf) { - if(_UC.calculationMethod==US_CM_META) line = g_strdup_printf("ERROR: can't open USPEX BESTIndividuals_relaxed file!\n"); + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) + line = g_strdup_printf("ERROR: can't open USPEX BESTIndividuals_relaxed file!\n"); else line = g_strdup_printf("ERROR: can't open USPEX BESTIndividuals file?!\n"); gui_text_show(ERROR, line); g_free(line); @@ -2678,6 +2708,9 @@ if(_UC.atomType==NULL){ g_free(line); line = file_read_line(vf); } +#if DEBUG_USPEX_READ +fprintf(stdout,"#DBG: N_BEST=%i ",_UO.num_best); +#endif fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ /*prepare (NEW) best_ind array*/ _UO.best_ind=g_malloc((2*_UO.num_best)*sizeof(gint)); @@ -2691,165 +2724,237 @@ if(_UC.atomType==NULL){ ptr=ptr2+1; _UO.best_ind[idx+1]=(gint)g_ascii_strtoull(ptr,NULL,10); } +#if DEBUG_USPEX_READ +fprintf(stdout,"{gen=%i idx=%i} ",_UO.best_ind[idx],_UO.best_ind[idx+1]); +#endif idx=idx+2; g_free(line); line = file_read_line(vf); } +#if DEBUG_USPEX_READ +fprintf(stdout,"\n"); +#endif /* +++ prepare ALL graph*/ _UO.graph=graph_new("ALL", model); /*process ALL graph ; ALL graph is _always_ enthalpy*/ min_E=_UO.min_E-(_UO.max_E-_UO.min_E)*0.05; max_E=_UO.max_E+(_UO.max_E-_UO.min_E)*0.05; - gen=0;iix=0; - if(!(_UC.calculationMethod==US_CM_META)) { + /*NEW - x dat*/ + gx.x_size=_UO.num_gen+1; + gx.x=g_malloc(gx.x_size*sizeof(gdouble)); + for(idx=0;idx0) { + gy.idx[ix]=_UO.ind[jdx].struct_number; + } else { + gy.idx[ix]=-1*jdx; + gy.symbol[ix]=GRAPH_SYMB_CROSS; + } #if DEBUG_USPEX_READ -fprintf(stdout,"E[%i]=e[%i]=%lf c[%i]=%c ",jdx,ix,e[ix],iix,ptr[iix]); +fprintf(stdout,"E[%i]=e[%i]=%lf c[%i]=%i ",jdx,ix,gy.y[ix],ix,gy.symbol[ix]); #endif - iix++; ix++; } - jdx++; - isok=(jdx<_UO.num_struct); - if(isok) isok&=(_UO.ind[jdx].gen<=gen); } /*add ALL data*/ #if DEBUG_USPEX_READ fprintf(stdout,"-SENT\n"); #endif - graph_add_borned_data(_UO.num_gen,e,0,_UO.num_gen,min_E,max_E,GRAPH_USPEX,_UO.graph); - /*to next gen*/ - g_free(e); - idx=jdx; +/* NEW - y dat*/ + gy.type=GRAPH_IX_TYPE; + gy.line=GRAPH_LINE_NONE; + dat_graph_add_y(gy,_UO.graph); + g_free(gy.y); + g_free(gy.idx); + g_free(gy.symbol); +/* END - NEW*/ +// idx=jdx; gen++; } - graph_set_color(ptr,_UO.graph); - g_free(ptr); /* +++ prepare BEST graph*/ - if(_UO.have_fitness) _UO.graph_best=graph_new("f_BEST", model); - else _UO.graph_best=graph_new("e_BEST", model); - ptr=g_malloc((1+_UO.num_best)*sizeof(gchar));/*NEW: graph "color"*/ - ptr[_UO.num_best]='\0';/*valgrind fix*/ + _UO.graph_best=graph_new("e_BEST", model); /*determine limits*/ - if(_UO.have_fitness){ - min_E=_UO.ind[_UO.best_ind[1]].fitness; - max_E=_UO.ind[_UO.best_ind[1]].fitness; - }else{ - min_E=_UO.ind[_UO.best_ind[1]].E; - max_E=_UO.ind[_UO.best_ind[1]].E; - } + min_E=_UO.ind[_UO.best_ind[1]].E; + max_E=_UO.ind[_UO.best_ind[1]].E; for(idx=0;idx<_UO.num_best;idx++){ - if(_UO.ind[_UO.best_ind[2*idx+1]].have_struct) { - ptr[idx]='O';/*ie. square*/ - if(_UO.have_fitness){ - if(_UO.ind[_UO.best_ind[2*idx+1]].fitness < min_E) min_E=_UO.ind[_UO.best_ind[2*idx+1]].fitness; - if(_UO.ind[_UO.best_ind[2*idx+1]].fitness > max_E) max_E=_UO.ind[_UO.best_ind[2*idx+1]].fitness; - }else{ - if(_UO.ind[_UO.best_ind[2*idx+1]].E < min_E) min_E=_UO.ind[_UO.best_ind[2*idx+1]].E; - if(_UO.ind[_UO.best_ind[2*idx+1]].E > max_E) max_E=_UO.ind[_UO.best_ind[2*idx+1]].E; - } - }else{ - ptr[idx]='X';/*ie. cross*/ - } + if(_UO.ind[_UO.best_ind[2*idx+1]].E < min_E) min_E=_UO.ind[_UO.best_ind[2*idx+1]].E; + if(_UO.ind[_UO.best_ind[2*idx+1]].E > max_E) max_E=_UO.ind[_UO.best_ind[2*idx+1]].E; } - /*for case where fitness is not properly calculated*/ + /*for case where energy is not properly calculated*/ if(max_E==min_E) { min_E-=0.1; max_E+=0.1; } - /*process BEST graph ; NEW: fitness or enthalpy*/ + /*process BEST graph*/ min_E=min_E-(max_E-min_E)*0.05; max_E=max_E+(max_E-min_E)*0.05; + /*NEW - x dat*/ + gx.x_size=_UO.num_gen+1; + gx.x=g_malloc(gx.x_size*sizeof(gdouble)); + for(idx=0;idx0) { + gy.idx[ix]=_UO.ind[_UO.best_ind[jdx+1]].struct_number; + gy.symbol[ix]=GRAPH_SYMB_SQUARE; + }else{ + gy.idx[ix]=-1*_UO.best_ind[jdx+1]; + gy.symbol[ix]=GRAPH_SYMB_CROSS; + } #if DEBUG_USPEX_READ -fprintf(stdout,"e[%i]=%lf ",ix,e[ix]); +fprintf(stdout,"e[%i]=%lf ",ix,gy.y[ix]); #endif - - ix++; - jdx+=2; - isok=(jdx<2*_UO.num_best); - if(isok) isok&=(_UO.best_ind[jdx]<=gen); + ix++; + } } #if DEBUG_USPEX_READ fprintf(stdout,"-SENT\n"); #endif - graph_add_borned_data(_UO.num_gen,e,0,_UO.num_gen,min_E,max_E,GRAPH_USPEX,_UO.graph_best); - g_free(e); + /* NEW - y dat*/ + dat_graph_add_y(gy,_UO.graph_best); + g_free(gy.y); + g_free(gy.idx); + g_free(gy.symbol); + /* END - NEW*/ /*to next gen*/ - idx=jdx; gen++; } - graph_set_color(ptr,_UO.graph_best); - g_free(ptr); - /*set ticks*/ +/* +++ add a set for lowest energy values*/ + max_E=_UO.max_E+(_UO.max_E-_UO.min_E)*0.15; + gy.y_size=_UO.num_gen+1; + gy.y=g_malloc(gy.y_size*sizeof(gdouble)); + gy.idx=NULL; + gy.symbol=g_malloc(gy.y_size*sizeof(graph_symbol)); + gy.type=GRAPH_IY_TYPE;/*CHANGED TYPE*/ + gy.line=GRAPH_LINE_DOT; + gen=0; + if(!((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP))) { + /*fake first point*/ + gy.y[0]=max_E;/*outside of graph*/ + gy.symbol[0]=GRAPH_SYMB_NONE; + gen=1; + } + idx=0; + while(gen<=_UO.num_gen){ + min_E=max_E; + for(jdx=idx;jdx<(2*_UO.num_best);jdx+=2){ + /*get the minimum value of this gen*/ + if(_UO.best_ind[jdx]==gen){ + if(_UO.ind[_UO.best_ind[jdx+1]].E-min_E<0.) min_E=_UO.ind[_UO.best_ind[jdx+1]].E; + idx=jdx; + } + } + gy.y[gen]=min_E; + gy.symbol[gen]=GRAPH_SYMB_NONE; + gen++; + } + dat_graph_add_y(gy,_UO.graph_best); + g_free(gy.y); + g_free(gy.symbol); +/* +++ ticks */ if(_UO.num_gen>15) ix=5; else ix=_UO.num_gen+1; graph_set_xticks(TRUE,ix,_UO.graph); @@ -2859,54 +2964,171 @@ fprintf(stdout,"-SENT\n"); /* --- variable composition */ /*there is extra graphs for variable composition*/ if((_UO.calc->_calctype_var)&&(_UC._nspecies>1)){ - /*calculate n_compo*/ - n_compo=n_data; _UO.graph_comp=g_malloc(_UC._nspecies*sizeof(gpointer)); for(species_index=0;species_index<_UC._nspecies;species_index++){ - /*one COMP graph per species*/ - tag=g_malloc(n_compo*sizeof(gdouble)); - c=g_malloc(n_compo*sizeof(gdouble)); - e=g_malloc(n_compo*sizeof(gdouble)); - ptr=g_malloc(1+n_compo*sizeof(gchar));/*NEW: graph "color"*/ - ptr[n_compo]='\0';/*\0 termination for valgrind*/ - jdx=0; - /*initialize with 1 to avoid gen=0 trouble*/ - c_sum=0;for(ix=0;ix<_UO.calc->_nspecies;ix++) c_sum+=_UO.ind[1].atoms[ix]; -/* +++ calculate all compositions*/ + min_E=_UO.min_E-(_UO.max_E-_UO.min_E)*0.05; + max_E=_UO.max_E+(_UO.max_E-_UO.min_E)*0.05; + n_compo=2; + gx.x_size=n_compo; + gx.x=g_malloc(n_compo*sizeof(gdouble)); + /*determine the different compositions*/ + gx.x[0]=0.; + gx.x[1]=1.; for(idx=0;idx<_UO.num_struct;idx++){ if(!_UO.ind[idx].have_data) continue; - if(_UO.ind[idx].have_struct) ptr[jdx]='O';/*ie. square*/ - else ptr[jdx]='X';/*ie. cross*/ - tag[jdx]=(gdouble)idx; c_sum=0;for(ix=0;ix<_UO.calc->_nspecies;ix++) c_sum+=_UO.ind[idx].atoms[ix]; - c[jdx]=(gdouble)(_UO.ind[idx].atoms[species_index])/c_sum; - e[jdx]=_UO.ind[idx].E; +if(c_sum==0) { + fprintf(stdout,"Something stupid is going on!\n"); + fprintf(stdout,"Ind %i atom: {",idx); + for(ix=0;ix<_UO.calc->_nspecies;ix++) fprintf(stdout,"%i ",_UO.ind[idx].atoms[ix]); + fprintf(stdout,"}\n"); + continue; +} + compo=(gdouble)(_UO.ind[idx].atoms[species_index])/c_sum; + if((compo>=1.0)||(compo<=0.0)) { + continue;/*rejected*/ + } + jdx=0; + while((jdxgx.x[jdx])) jdx++; + if((compo-gx.x[jdx])==0.) continue;/*we already have that one*/ + c=g_malloc((n_compo+1)*sizeof(gdouble)); + jdx=0; + for(jdx=0;(compo>gx.x[jdx])&&(jdx_nspecies;ix++) c_sum+=_UO.ind[idx].atoms[ix]; + compo=(gdouble)(_UO.ind[idx].atoms[species_index])/c_sum; + if((compo-gx.x[jdx])!=0.0) continue; + num++; + if(gy.y==NULL){ + c=g_malloc(1*sizeof(gdouble)); + c_idx=g_malloc(1*sizeof(gint32)); + c_sym=g_malloc(1*sizeof(graph_symbol)); + }else{ + c=g_malloc(num*sizeof(gdouble)); + memcpy(c,gy.y,(num-1)*sizeof(gdouble)); + c_idx=g_malloc(num*sizeof(gint32)); + memcpy(c_idx,gy.idx,(num-1)*sizeof(gint32)); + c_sym=g_malloc(num*sizeof(graph_symbol)); + memcpy(c_sym,gy.symbol,(num-1)*sizeof(graph_symbol)); + g_free(gy.y); + g_free(gy.idx); + g_free(gy.symbol); + } + c[num-1]=_UO.ind[idx].E; + if(c[num-1]0) { + c_idx[num-1]=_UO.ind[idx].struct_number; + c_sym[num-1]=GRAPH_SYMB_SQUARE; + }else{ + c_idx[num-1]=-1*idx; + c_sym[num-1]=GRAPH_SYMB_CROSS; + } + gy.y=c; + gy.idx=c_idx; + gy.symbol=c_sym; + gy.type=GRAPH_XX_TYPE; + } + gy.y_size=num; + dat_graph_add_y(gy,_UO.graph_comp[species_index]); + if(num>0){ + g_free(gy.y); + g_free(gy.idx); + g_free(gy.symbol); + } + } /*set ticks*/ graph_set_xticks(TRUE,3,_UO.graph_comp[species_index]); graph_set_yticks(TRUE,5,_UO.graph_comp[species_index]); +/* +++ add a set for convex hull*/ + gy.y_size=n_compo; + gy.y=g_malloc(n_compo*sizeof(gdouble)); + gy.idx=g_malloc(n_compo*sizeof(gint32)); + gy.symbol=g_malloc(n_compo*sizeof(graph_symbol)); + gy.type=GRAPH_IY_TYPE;/*CHANGED TYPE*/ + gy.line=GRAPH_LINE_DASH; + /*1- look for the minimum of minimum*/ + min=0; + for(idx=0;idx0;idx--){ + compo=(c_min[min]-c_min[idx])/(gx.x[min]-gx.x[idx]); + if(compo>min_E){ + min_E=compo; + med=idx; + } + } + gy.y[med]=c_min[med]; + gy.idx[med]=-1; + gy.symbol[med]=GRAPH_SYMB_DIAM; + if(gx.x[med]==0.) max_E=gy.y[med]; + else max_E=(gy.y[min]-(gy.y[med]*gx.x[min]/gx.x[med]))/(1.0-(gx.x[min]/gx.x[med])); + for(idx=min-1;idx>med;idx--){ + gy.y[idx]=min_E*gx.x[idx]+max_E;/*ie y=ax+b*/ + gy.idx[idx]=-1; + gy.symbol[idx]=GRAPH_SYMB_NONE; + } + min=med; +} +/* +++ right */ +while(max!=n_compo-1){ + max_E=(c_min[n_compo-1]-c_min[max])/(gx.x[n_compo-1]-gx.x[max]); + med=n_compo-1; + for(idx=max+1;idx<(n_compo-1);idx++){ + compo=(c_min[idx]-c_min[max])/(gx.x[idx]-gx.x[max]); + if(compo image coordinate*/ + gx.x_size=_UO.num_gen; + gx.x=g_malloc(gx.x_size*sizeof(gdouble)); + for(idx=0;idx image data*/ + gy.y_size=_UO.num_gen; + gy.y=g_malloc(gy.y_size*sizeof(gdouble)); + gy.idx=g_malloc(gy.y_size*sizeof(gint32)); + gy.symbol=g_malloc(gy.y_size*sizeof(graph_symbol)); + sscanf(line," %*i %lf %*s",&(gy.y[1])); + gy.y[1] /= (gdouble)natoms; + _UO.min_E=gy.y[1]; + _UO.max_E=gy.y[1]; + /*create a fake image_0*/ + _UO.ind[0].gen=0; + _UO.ind[0].have_data=FALSE; + _UO.ind[0].struct_number=0; + for(idx=1;idx<_UO.num_gen;idx++){ if(!line) break;/*<- useful? */ sscanf(line," %*i %lf %*s",&(_UO.ind[idx].energy)); _UO.ind[idx].atoms=g_malloc(_UC._nspecies*sizeof(gint)); _UO.ind[idx].natoms=natoms;/*<-constant*/ _UO.ind[idx].E = _UO.ind[idx].energy / (gdouble)_UO.ind[idx].natoms; - _UO.ind[idx].gen=idx;/*<- this is actually *not* true*/ - _UO.best_ind[idx+1]=idx; - e[idx+1]=_UO.ind[idx].E; - if(e[idx+1]<_UO.min_E) _UO.min_E=e[idx+1]; - if(e[idx+1]>_UO.max_E) _UO.max_E=e[idx+1]; + _UO.ind[idx].gen=idx; + _UO.best_ind[idx]=idx; + _UO.ind[idx].struct_number=idx; + gy.y[idx]=_UO.ind[idx].E; + gy.idx[idx]=idx; + gy.symbol[idx]=GRAPH_SYMB_DIAM; + gy.type=GRAPH_IY_TYPE; + if(gy.y[idx]<_UO.min_E) _UO.min_E=gy.y[idx]; + if(gy.y[idx]>_UO.max_E) _UO.max_E=gy.y[idx]; #if DEBUG_USPEX_READ -fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.ind[idx].gen,_UO.ind[idx].natoms,_UO.ind[idx].energy,e[idx]); +fprintf(stdout,"#DBG: VCNEB Image %i: natoms=%i energy=%lf e=%lf\n",_UO.ind[idx].gen,_UO.ind[idx].natoms,_UO.ind[idx].energy,_UO.ind[idx].E); #endif g_free(line); line = file_read_line(vf); } fclose(vf);vf=NULL; g_free(aux_file); + min_E=_UO.min_E-(_UO.max_E-_UO.min_E)*0.05; + max_E=_UO.max_E+(_UO.max_E-_UO.min_E)*0.05; + dat_graph_set_limits(0,_UO.num_gen,min_E,max_E,_UO.graph_best); + gy.line=GRAPH_LINE_DASH; + dat_graph_add_y(gy,_UO.graph_best); + g_free(gy.y); + g_free(gy.idx); + g_free(gy.symbol); + /*set ticks*/ + if(_UO.num_gen>15) ix=5; + else ix=_UO.num_gen+1; + graph_set_xticks(TRUE,ix,_UO.graph_best); + graph_set_yticks(TRUE,5,_UO.graph_best); /* --- reopen transitionPath_POSCARs or the newly created transitionPath_POSCARs5 file for reading * ^^^ this will be our new model file*/ if(_UO.version<1010) aux_file = g_strdup_printf("%s%s",res_folder,"transitionPath_POSCARs5"); else aux_file = g_strdup_printf("%s%s",res_folder,"transitionPath_POSCARs"); vf=fopen(aux_file,"rt"); - if (!vf) {/*very unlikely: we just create it*/ + if (!vf) {/*very unlikely: we just create/read it*/ g_free(_UO.ind); if(_UO.version<1010) line = g_strdup_printf("ERROR: can't open USPEX transitionPath_POSCARs5 file!\n"); else line = g_strdup_printf("ERROR: can't open USPEX transitionPath_POSCARs file!\n"); @@ -3071,10 +3339,8 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i model->num_frames=0; vfpos=ftell(vf);/* flag */ line = file_read_line(vf); - idx=0; while(!feof(vf)){ if (find_in_string("Image",line) != NULL) { - idx=0; fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ add_frame_offset(vf, model); model->num_frames++; @@ -3084,25 +3350,14 @@ fprintf(stdout,"#DBG: USPEX[VCNEB] Image %i: natoms=%i energy=%lf e=%lf\n",_UO.i vfpos=ftell(vf);/* flag */ g_free(line); line = file_read_line(vf); - idx++; } - strcpy(model->filename,aux_file);// which means that we "forget" about OUTPUT.txt - g_free(aux_file); - rewind(vf); - read_frame_uspex(vf,model);/*open first frame*/ - fclose(vf);vf=NULL; - /*do a "best" graph with each image*/ - _UO.graph_best=graph_new("PATH", model); - _UO.num_gen=_UO.num_struct; - graph_add_borned_data( - _UO.num_gen,e,0,_UO.num_gen, - _UO.min_E-(_UO.max_E-_UO.min_E)*0.05,_UO.max_E+(_UO.max_E-_UO.min_E)*0.05,GRAPH_USPEX_BEST,_UO.graph_best); - g_free(e); - /*set ticks*/ - if(_UO.num_gen>15) ix=5; - else ix=_UO.num_gen+1; - graph_set_xticks(TRUE,ix,_UO.graph_best); - graph_set_yticks(TRUE,5,_UO.graph_best); + strcpy(model->filename,aux_file);// which means that we "forget" about OUTPUT.txt + g_free(aux_file); + g_free(model->basename); + model->basename=g_strdup_printf("uspex"); + rewind(vf); + read_frame_uspex(vf,model);/*open first frame*/ + fclose(vf);vf=NULL; /*refresh model*/ tree_model_refresh(model); model->redraw = TRUE; @@ -3160,17 +3415,56 @@ if(_UO.ind[idx].have_data){ property_add_ranked(4, "Volume", line, model); g_free(line); /*note: Formula property rank is 7*/ - line=g_strdup_printf("%i",idx); +if(_UO.ind[idx].struct_number>=0){/*useless for now: no frame means no read_frame*/ + line=g_strdup_printf("%i",_UO.ind[idx].struct_number); +}else{ + /*note: there is no way to reach here from read_frame_uspex*/ + line=g_strdup_printf("N/A"); +} property_add_ranked(8, "Structure", line, model); g_free(line); - if(_UO.have_fitness){ - line=g_strdup_printf("%f f",_UO.ind[idx].fitness); - property_add_ranked(9, "Fitness", line, model); - g_free(line); +} + return 0; +} +/****************************/ +/* update frame information */ +/****************************/ +gint update_frame_uspex(gint idx,struct model_pak *model){ +/*this is used when there is data, but no structure*/ + gchar *line; + uspex_output_struct *uspex_output=model->uspex; + /*formula*/ + gint i; + gchar *spec; + /**/ + if(idx<0) idx*=-1; +if(_UO.ind[idx].have_data){ + line=g_strdup_printf("%lf eV",_UO.ind[idx].energy); + property_add_ranked(3, "Energy", line, model); + model->volume=_UO.ind[idx].volume; + g_free(line);line=g_strdup_printf("%lf uV",model->volume); + property_add_ranked(4, "Volume", line, model); + g_free(line); + line=g_strdup_printf("%c",'\0'); + for(i=0;i<_UO.calc->_nspecies;i++) { + spec=g_strdup_printf("%s(%i)",elements[_UO.calc->atomType[i]].symbol,_UO.ind[idx].atoms[i]); + line=g_strdup_printf("%s%s",line,spec); + g_free(spec); + } + property_add_ranked(7, "Formula", line, model); + g_free(line); + if(_UO.ind[idx].struct_number>=0){ + line=g_strdup_printf("%i",_UO.ind[idx].struct_number); + }else{ + line=g_strdup_printf("N/A"); } + property_add_ranked(8, "Structure", line, model); + g_free(line); + model_prep(model);/*maybe a little too much!*/ } return 0; } + #undef _UO diff --git a/src/file_uspex.h b/src/file_uspex.h index 302b723..7fe2cc4 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -91,7 +91,7 @@ typedef enum { } uspex_bt_goal; typedef struct { gboolean have_data; /*NEW: allow incomplete Individuals*/ - gboolean have_struct; /*NEW: allow incomplete gatheredPOSCARS*/ + gint struct_number; /*NEW: allow incomplete gatheredPOSCARS*/ gint gen; /*generation of this individual*/ gint natoms; /*number of atoms*/ gint *atoms; /*number of atoms per species*/ diff --git a/src/gl_graph.c b/src/gl_graph.c index 522ebbe..31150d7 100644 --- a/src/gl_graph.c +++ b/src/gl_graph.c @@ -120,7 +120,6 @@ graph->ymax = 0.0; graph->xticks = 5; graph->yticks = 5; graph->size = 0; -graph->color = NULL; graph->select = -1; graph->select_label = NULL; graph->set_list = NULL; @@ -175,7 +174,7 @@ void graph_set_xticks(gint label, gint ticks, gpointer ptr_graph) struct graph_pak *graph = ptr_graph; g_assert(graph != NULL); -g_assert(ticks > 1);/* FIXME: ticks shouldn't matter if label=FALSE */ +if(label) g_assert(ticks > 1); graph->xlabel = label; graph->xticks = ticks; @@ -189,7 +188,7 @@ void graph_set_yticks(gint label, gint ticks, gpointer ptr_graph) struct graph_pak *graph = ptr_graph; g_assert(graph != NULL); -g_assert(ticks > 1);/* FIXME: ticks shouldn't matter if label=FALSE */ +if(label) g_assert(ticks > 1); graph->ylabel = label; graph->yticks = ticks; @@ -272,8 +271,6 @@ struct graph_pak *graph = data; g_assert(graph != NULL); -/* try to prevent the user supplying different sized data */ -/* TODO - sample in some fashion if different? */ if(type==GRAPH_BANDOS){ /*the first *two* sets of a GRAPH_BANDOS are _not_ the same size*/ /*also it doesn't make much sense to allow anything on that one.*/ @@ -293,13 +290,8 @@ else graph->size = size; } -if((type==GRAPH_USPEX)||(type==GRAPH_USPEX_BEST)){ -ptr = g_malloc((1+(gint)x[0])*sizeof(gdouble));/*_VALGRIND_BUG_ (misplaced parenthesis)*/ -memcpy(ptr,&(x[0]),(1+(gint)x[0])*sizeof(gdouble)); -}else{ ptr = g_malloc(size*sizeof(gdouble)); memcpy(ptr, x, size*sizeof(gdouble)); -} graph->xmin = x_min; graph->xmax = x_max; @@ -310,13 +302,95 @@ graph->type=type; graph->set_list = g_slist_append(graph->set_list, ptr); } +/*************************/ +/* NEW - dat_graph: set x*/ +/*************************/ +void dat_graph_set_x(g_data_x dx,gpointer pgraph){ +struct graph_pak *graph = pgraph; +int i; +g_data_x *px; + +g_assert(graph != NULL); + +/*duplicate and register*/ +px=g_malloc(sizeof(g_data_x)); +g_assert(px != NULL); +px->x_size = dx.x_size; +px->x = g_malloc(dx.x_size*sizeof(gdouble)); +//memcpy(px->x,dx.x,dx.x_size*sizeof(gdouble)); +for(i=0;ix[i]=dx.x[i]; + +graph->size=0;/*graph size hold the number of y arrays!*/ +graph->set_list = g_slist_append(graph->set_list, px); +} /**************************/ -/* set graph data "color" */ +/* NEW - dat_graph: add y */ /**************************/ -void graph_set_color(gchar *color,gpointer data){ - struct graph_pak *graph = data; - if(graph->color!=NULL) g_free(graph->color); - graph->color=g_strdup(color); +void dat_graph_add_y(g_data_y dy,gpointer pgraph){ +struct graph_pak *graph = pgraph; +g_data_y *py; + +g_assert(graph != NULL); + +if(dy.y_size==0) { + /*empty size data set are OK*/ + py=g_malloc(sizeof(g_data_y)); + py->y_size=0; + py->y=NULL; + py->idx=NULL; + py->type=GRAPH_REGULAR; + py->symbol=NULL; + py->line=GRAPH_LINE_NONE; + py->color=0; + graph->size++;/*graph size hold the number of y arrays!*/ + graph->set_list = g_slist_append(graph->set_list, py); + return; +} +/*duplicate and register*/ +py=g_malloc(sizeof(g_data_y)); +g_assert(py != NULL); +py->y_size=dy.y_size; +py->y=g_malloc(dy.y_size*sizeof(gdouble)); +memcpy(py->y,dy.y,dy.y_size*sizeof(gdouble)); +if(dy.idx==NULL) py->idx=NULL; +else{ + py->idx=g_malloc(dy.y_size*sizeof(gint32)); + memcpy(py->idx,dy.idx,dy.y_size*sizeof(gint32)); +} +if(dy.symbol==NULL) py->symbol=NULL; +else{ + py->symbol=g_malloc(dy.y_size*sizeof(graph_symbol)); + memcpy(py->symbol,dy.symbol,dy.y_size*sizeof(graph_symbol)); +} +py->line=dy.line; +py->color=dy.color; +py->type=dy.type; + +graph->size++;/*graph size hold the number of y arrays!*/ +graph->set_list = g_slist_append(graph->set_list, py); +} +/*******************************/ +/* NEW - dat_graph: set limits */ +/*******************************/ +void dat_graph_set_limits(gdouble x_min,gdouble x_max,gdouble y_min,gdouble y_max,gpointer pgraph){ +struct graph_pak *graph = pgraph; + +g_assert(graph != NULL); + +graph->xmin = x_min; +graph->xmax = x_max; +graph->ymin = y_min; +graph->ymax = y_max; +} +/*******************************/ +/* NEW - set global graph type */ +/*******************************/ +void dat_graph_set_type(graph_type type,gpointer pgraph){ +struct graph_pak *graph = pgraph; + +g_assert(graph != NULL); + +graph->type=type; } /*********************************************/ /* select a value in a GRAPH_FREQUENCY graph */ @@ -355,30 +429,29 @@ for (list=graph->set_list ; list ; list=g_slist_next(list)) } } } -/***************************************/ -/* Select a value in GRAPH_USPEX graph */ -/***************************************/ -void graph_uspex_select(gint x, gint y, struct model_pak *model){ -/*when selected, print value and open the corresponding structure file*/ +/***********************************/ +/* NEW - dat_graph: select a value */ +/***********************************/ +void dat_graph_select(gint x, gint y, struct model_pak *model){ struct graph_pak *graph; struct canvas_pak *canvas; - gint struct_sel; - gdouble ox,dx; - gdouble oy,dy,yf; - gint yy; + gdouble ox,dx, xf; + gdouble oy,dy, yf; + gint xx,yy; int i,j; - gdouble *ptr; GSList *list; -/*just a try*/ - FILE *vf; - gint n_struct; - /*get the selected structure*/ + FILE *vf; + gint x_index; + gint y_index; + g_data_x *p_x; + g_data_y *p_y; + g_assert(model!=NULL); - graph=(struct graph_pak *)model->graph_active; + graph=(struct graph_pak *)model->graph_active; g_assert(graph!=NULL); - canvas = g_slist_nth_data(sysenv.canvas_list, 0); + canvas = g_slist_nth_data(sysenv.canvas_list, 0); g_assert(canvas!=NULL); -/*calculate real data*/ +/*calculate x data*/ ox=canvas->x + 4*gl_fontsize; if (graph->ylabel) ox+=4*gl_fontsize; oy=canvas->y + canvas->height - 2*gl_fontsize; @@ -386,158 +459,99 @@ g_assert(canvas!=NULL); dy=(canvas->height-8.0*gl_fontsize); dx=(canvas->width-2.0*ox); - struct_sel=(gint)(0.25+((x-ox)/dx)*(graph->size));/*generation*/ - struct_sel--; - -/*check if the data point exists*/ -if((struct_sel<0)||(struct_sel>graph->size-1)) return;/*not in there*/ - -/*USPEX_BEST: simple search*/ -if(graph->type==GRAPH_USPEX_BEST){ -list=graph->set_list;/*there should be only one list*/ -ptr = (gdouble *) list->data; -i = struct_sel + 1; -yf = ptr[i]; -yf -= graph->ymin; -yf /= (graph->ymax - graph->ymin); -yf *= dy; -yy = (gint) yf; -yy *= -1; -yy += oy; -if((y>yy-3)&&(yuspex; - /*we have a hit*/ - graph->select=struct_sel; - graph->select_2=ptr[i]; - g_free(graph->select_label); - graph->select_label=g_strdup_printf("[%i,%f]",struct_sel+1,ptr[i]); - vf=fopen(model->filename, "r"); - if(!vf) return; - model->cur_frame=(*uspex_output).best_ind[struct_sel+1];/*this is the structure number*/ - read_raw_frame(vf,model->cur_frame,model); - fclose(vf); - tree_model_refresh(model); - model_prep(model); - return;/*no need to continue for all data!*/ -} -}else{ -/*USPEX: more complex search*/ -j=-1;n_struct=0; -for (list=graph->set_list ; list ; list=g_slist_next(list)) - { - if(j>struct_sel) return; - if(jdata; - n_struct+=(gint)ptr[0]; - j++; - continue; - }else{ - /*we are on the good set*/ - ptr = (gdouble *) list->data; - for(i=1;i<=(gint)ptr[0];i++){ - yf = ptr[i]; - yf -= graph->ymin; - yf /= (graph->ymax - graph->ymin); - yf *= dy; - yy = (gint) yf; - yy *= -1; - yy += oy; - if((y>yy-3)&&(yuspex; - /*we have a hit*/ - graph->select=struct_sel; - graph->select_2=ptr[i]; - g_free(graph->select_label); - graph->select_label=g_strdup_printf("[%i,%f]",struct_sel+1,ptr[i]); + list=graph->set_list; + p_x = (g_data_x *) list->data; + /*get the corresponding x index*/ + x_index=-1; + for(i=0;ix_size;i++){ + xf = p_x->x[i]; + xf -= graph->xmin; + xf /= (graph->xmax - graph->xmin); + xx = ox + xf*dx; + if((x>xx-3)&&(xtype==GRAPH_IY_TYPE)||(graph->type==GRAPH_XY_TYPE)){ + for ( ; list ; list=g_slist_next(list)){ + p_y = (g_data_y *) list->data; + yf = p_y->y[x_index];/*only need to look here*/ + yf -= graph->ymin; + yf /= (graph->ymax - graph->ymin); + yf *= dy; + yy = (gint) yf; + yy *= -1; + yy += oy; + if((y>yy-3)&&(yselect=x_index; + graph->select_2=p_y->y[x_index]; + if(graph->select_label) g_free(graph->select_label); + if(graph->type==GRAPH_IY_TYPE) graph->select_label=g_strdup_printf("[%i,%f]",(gint)p_x->x[x_index],p_y->y[x_index]); + else graph->select_label=g_strdup_printf("[%G,%G]",p_x->x[x_index],p_y->y[x_index]); + if(p_y->idx!=NULL) { + if(p_y->idx[x_index]<0) { + update_frame_uspex(p_y->idx[x_index]-1,model); + return;/*unavailable*/ + } + /*load structure*/ vf=fopen(model->filename, "r"); if(!vf) return; -// if((*uspex_output).calc->calculationMethod==US_CM_META) n_struct++; - model->cur_frame=n_struct+i-1; - read_raw_frame(vf,n_struct+i-1,model); + model->cur_frame=p_y->idx[x_index]-1; + read_raw_frame(vf,p_y->idx[x_index]-1,model); fclose(vf); tree_model_refresh(model); model_prep(model); - return;/*no need to continue for all data!*/ } + break; } j++; } - } -} -} -/******************************************/ -/* Select a value in GRAPH_USPEX_2D graph */ -/******************************************/ -void graph_uspex_2d_select(gint x, gint y, struct model_pak *model){ -/*when selected, print value and open the corresponding structure file*/ - struct graph_pak *graph; - struct canvas_pak *canvas; - gdouble ox,dx, xf; - gdouble oy,dy, yf; - gint xx,yy; - int i; - gdouble *xval; - gdouble *yval; - gdouble *tag; - GSList *list; - FILE *vf; - /*get the selected structure*/ -g_assert(model!=NULL); - graph=(struct graph_pak *)model->graph_active; -g_assert(graph!=NULL); - canvas = g_slist_nth_data(sysenv.canvas_list, 0); -g_assert(canvas!=NULL); -/*calculate real data*/ - ox=canvas->x + 4*gl_fontsize; - if (graph->ylabel) ox+=4*gl_fontsize; - oy=canvas->y + canvas->height - 2*gl_fontsize; - if (graph->xlabel) oy-=2*gl_fontsize; - dy=(canvas->height-8.0*gl_fontsize); - dx=(canvas->width-2.0*ox); - -/*first set is tags*/ -list=graph->set_list; -tag = (gdouble *) list->data; -list=g_slist_next(list); -/*second set is x*/ -xval = (gdouble *) list->data; -list=g_slist_next(list); - -for ( ; list ; list=g_slist_next(list)){ - i=0; - yval = (gdouble *) list->data; - while(isize){ - xf = xval[i]; - xf -= graph->xmin; - xf /= (graph->xmax - graph->xmin); - xx = ox + xf*dx; - if((x>xx-3)&&(xtype==GRAPH_IX_TYPE)||(graph->type==GRAPH_XX_TYPE)){ + /*in this case, we know the data is on the x_index set*/ + list=g_slist_nth(graph->set_list,x_index+1); + if(!list) return;/*missing data?*/ + p_y = (g_data_y *) list->data; + for(j=0;jy_size;j++){ + yf = p_y->y[j]; yf -= graph->ymin; yf /= (graph->ymax - graph->ymin); yf *= dy; yy = (gint) yf; yy *= -1; yy += oy; - if((y>yy-3)&&(yselect=i; - graph->select_2=yval[i]; - g_free(graph->select_label); - graph->select_label=g_strdup_printf("[%f,%f]",xval[i],yval[i]); - vf=fopen(model->filename, "r"); - if(!vf) return; - model->cur_frame=tag[i]; - read_raw_frame(vf,tag[i],model); - fclose(vf); - tree_model_refresh(model); - model_prep(model); - return;/*no need to continue for all data!*/ + if((y>yy-3)&&(yselect=x_index; + graph->select_2=p_y->y[y_index]; + if(graph->select_label) g_free(graph->select_label); + if(graph->type==GRAPH_IX_TYPE) graph->select_label=g_strdup_printf("[%i,%f]",(gint)p_x->x[x_index],p_y->y[y_index]); + else graph->select_label=g_strdup_printf("[%G,%G]",p_x->x[x_index],p_y->y[y_index]); + if(p_y->idx!=NULL) { + if(p_y->idx[y_index]<0) { + update_frame_uspex(p_y->idx[y_index],model); + return;/*unavailable*/ + } + /*load structure*/ + vf=fopen(model->filename, "r"); + if(!vf) return; + model->cur_frame=p_y->idx[y_index]; + read_raw_frame(vf,p_y->idx[y_index],model); + fclose(vf); + tree_model_refresh(model); + model_prep(model); + } + break; } } - i++; - } - -} + }else return;/*unknown graph type*/ } /************************************/ /* graph data extraction primitives */ @@ -579,7 +593,6 @@ void graph_draw_new(struct canvas_pak *canvas, struct graph_pak *graph){ gint i, j, x, y, oldx, oldy, ox, oy, sx, sy; gint flag; gchar *text; -gchar *color=&(graph->color[0]); gdouble *ptr; gdouble xf, yf, dx, dy; GSList *list; @@ -591,6 +604,11 @@ gdouble sz; gdouble *xval=NULL; gdouble xmin=0.; gdouble xmax=0.; +/*NEW - dat_graph*/ +g_data_x *gx=NULL; +g_data_y *gy=NULL; +graph_type type=graph->type; +graph_line line=GRAPH_LINE_NONE; /* compute origin */ ox = canvas->x + 4*gl_fontsize; if (graph->ylabel) ox += 4*gl_fontsize; @@ -603,7 +621,7 @@ dx = (canvas->width-2.0*ox); glColor3f(sysenv.render.fg_colour[0],sysenv.render.fg_colour[1],sysenv.render.fg_colour[2]); glLineWidth(2.0); /* x labels */ -if((graph->type==GRAPH_DOS)&&(graph->xticks>2)){ +if((type==GRAPH_DOS)&&(graph->xticks>2)){ /* we WANT 0 to be a tick, if nticks>2 */ sz=(graph->xmax-graph->xmin)/(graph->xticks);/*size of a tick*/ shift=(gint)(graph->xmin/sz); @@ -640,14 +658,14 @@ if((graph->type==GRAPH_DOS)&&(graph->xticks>2)){ for (i=0 ; ixticks ; i++){ /* get real index */ xf = (gdouble) i / (gdouble) (graph->xticks-1); - if(graph->type==GRAPH_BANDOS){ + if(type==GRAPH_BANDOS){ x = ox + xf*dx*0.3; }else{ x = ox + xf*dx; } if (graph->xlabel){ /*only calculate real value when needed*/ - if(graph->type!=GRAPH_BANDOS){ + if(type!=GRAPH_BANDOS){ xf *= (graph->xmax-graph->xmin); xf += graph->xmin; } @@ -665,7 +683,7 @@ if((graph->type==GRAPH_DOS)&&(graph->xticks>2)){ } } /* another x axis */ -if(graph->type==GRAPH_BANDOS){ +if(type==GRAPH_BANDOS){ /*second x axis*/ oldx = ox+dx*0.4; for (i=0 ; ixticks ; i++){ @@ -688,7 +706,7 @@ if(graph->type==GRAPH_BANDOS){ } } /* y labels */ -if(((graph->type==GRAPH_BANDOS)||(graph->type==GRAPH_BAND))&&(graph->yticks>2)){ +if(((type==GRAPH_BANDOS)||(type==GRAPH_BAND))&&(graph->yticks>2)){ /* we WANT 0 to be a tick, if nticks>2 */ sz=(graph->ymax-graph->ymin)/(graph->yticks);/*size of a tick*/ shift=(gint)(graph->ymin/sz); @@ -752,7 +770,7 @@ if(((graph->type==GRAPH_BANDOS)||(graph->type==GRAPH_BAND))&&(graph->yticks>2)){ } } /* another y axis */ -if(graph->type==GRAPH_BANDOS){ +if(type==GRAPH_BANDOS){ x=ox+0.4*dx; y=oy-dy; oldy=oy; @@ -812,7 +830,7 @@ flag = FALSE; sx = sy = 0; list=graph->set_list; size=graph->size; -if(graph->type==GRAPH_BANDOS){ +if(type==GRAPH_BANDOS){ /*first set is the DOS, to put on [0,0.3] of x, rotated by 90 degrees*/ ptr = (gdouble *) list->data; glBegin(GL_LINE_STRIP); @@ -844,47 +862,65 @@ if(graph->type==GRAPH_BANDOS){ size=nkpoints; list=g_slist_next(list); } -if(graph->type==GRAPH_BAND){ +if(type==GRAPH_BAND){ /*the first set of GRAPH_BAND data contain X values*/ /*we do not read the full header (yet)*/ ptr = (gdouble *) list->data; xval=&(ptr[4]); list=g_slist_next(list); } -if(graph->type==GRAPH_USPEX_2D){ -/*first set is the tags, ignore*/ -list=g_slist_next(list); -/*second set is x*/ - ptr = (gdouble *) list->data; - xval=&(ptr[0]); +if((type==GRAPH_IY_TYPE) + ||(type==GRAPH_XY_TYPE) + ||(type==GRAPH_IX_TYPE) + ||(type==GRAPH_XX_TYPE)){ +/*we have dedicated x,y*/ + gx=(g_data_x *)list->data; + xval=&(gx->x[0]); list=g_slist_next(list); } j=0; for ( ; list ; list=g_slist_next(list)) { - ptr = (gdouble *) list->data; + /*FIXME here with ALL graph*/ + if((type==GRAPH_IY_TYPE) + ||(type==GRAPH_XY_TYPE) + ||(type==GRAPH_IX_TYPE) + ||(type==GRAPH_XX_TYPE)){ + gy=(g_data_y *)list->data; + ptr=&(gy->y[0]); + size=gy->y_size; + line=gy->line; + if((ptr==NULL)||(size==0)){ + /*empty data set is OK*/ + j++; + continue; + } + if(gy->type!=GRAPH_REGULAR) type=gy->type; + } else { + ptr = (gdouble *) list->data; + } oldx=-1; oldy=-1; i=0; - if(graph->type==GRAPH_USPEX) size=(gint)ptr[0]; while(itype){ - case GRAPH_USPEX_BEST: - xf = (gdouble) (i); - yf = ptr[i+1]; +switch (type){ + case GRAPH_IY_TYPE: + case GRAPH_XY_TYPE: + xf = xval[i]; + yf = ptr[i]; break; - case GRAPH_USPEX: - xf = (gdouble) (j); - yf = ptr[i+1]; + case GRAPH_IX_TYPE: + case GRAPH_XX_TYPE: + xf = xval[j]; + yf = ptr[i]; break; case GRAPH_FREQUENCY: case GRAPH_DOS: xf = ptr[i]; yf = ptr[i+1]; break; - case GRAPH_USPEX_2D: case GRAPH_BANDOS: case GRAPH_BAND: xf = xval[i]; @@ -899,13 +935,14 @@ switch (graph->type){ /*new: skip drawing for points outside of graph extrema (also interrupt line when line drawing)*/ if((xfxmin)||(xf>graph->xmax)||(yfymin)||(yf>graph->ymax)) { /*update index*/ - switch(graph->type){ + switch(type){ case GRAPH_FREQUENCY: case GRAPH_DOS: i++;/* ie twice ++ */ - case GRAPH_USPEX_2D: - case GRAPH_USPEX_BEST: - case GRAPH_USPEX: + case GRAPH_IY_TYPE: + case GRAPH_XY_TYPE: + case GRAPH_IX_TYPE: + case GRAPH_XX_TYPE: case GRAPH_BAND: case GRAPH_BANDOS: case GRAPH_REGULAR: @@ -916,7 +953,7 @@ if((xfxmin)||(xf>graph->xmax)||(yfymin)||(yf>graph->ymax)) { continue; } /*calculate screen values*/ -switch (graph->type){ +switch (type){ case GRAPH_FREQUENCY: /*we can draw impulse directly*/ glBegin(GL_LINE_STRIP); @@ -965,52 +1002,11 @@ switch (graph->type){ y *= -1; y += oy; break; - case GRAPH_USPEX_BEST: - case GRAPH_USPEX: + case GRAPH_IY_TYPE: + case GRAPH_XY_TYPE: + case GRAPH_IX_TYPE: + case GRAPH_XX_TYPE: // xf += 1.; - xf /= (gdouble) (graph->size);/*NOT size*/ - x = ox + xf*dx; - yf -= graph->ymin; - yf /= (graph->ymax - graph->ymin); - yf *= dy; - y = (gint) yf; - y *= -1; - y += oy; -if(color!=NULL){ - if(*color=='O'){ - /*draw a rectangle*/ - glBegin(GL_LINE_STRIP); - gl_vertex_window(x-2, y-2, canvas); - gl_vertex_window(x+2, y-2, canvas); - gl_vertex_window(x+2, y+2, canvas); - gl_vertex_window(x-2, y+2, canvas); - gl_vertex_window(x-2, y-2, canvas); - glEnd(); - color++; - }else if(*color=='X'){ - /*draw a cross*/ - glBegin(GL_LINE_STRIP); - gl_vertex_window(x-2, y-2, canvas); - gl_vertex_window(x+2, y+2, canvas); - glEnd(); - glBegin(GL_LINE_STRIP); - gl_vertex_window(x+2, y-2, canvas); - gl_vertex_window(x-2, y+2, canvas); - glEnd(); - color++; - } -}else{ - /*draw a default rectangle*/ - glBegin(GL_LINE_STRIP); - gl_vertex_window(x-2, y-2, canvas); - gl_vertex_window(x+2, y-2, canvas); - gl_vertex_window(x+2, y+2, canvas); - gl_vertex_window(x-2, y+2, canvas); - gl_vertex_window(x-2, y-2, canvas); - glEnd(); -} - break; - case GRAPH_USPEX_2D: xf -= graph->xmin; xf /= (graph->xmax - graph->xmin); x = ox + xf*dx; @@ -1020,29 +1016,57 @@ if(color!=NULL){ y = (gint) yf; y *= -1; y += oy; -if(color!=NULL){ - if(*color=='O'){ - /*draw a rectangle*/ - glBegin(GL_LINE_STRIP); - gl_vertex_window(x-2, y-2, canvas); - gl_vertex_window(x+2, y-2, canvas); - gl_vertex_window(x+2, y+2, canvas); - gl_vertex_window(x-2, y+2, canvas); - gl_vertex_window(x-2, y-2, canvas); - glEnd(); - color++; - }else if(*color=='X'){ - /*draw a cross*/ - glBegin(GL_LINE_STRIP); - gl_vertex_window(x-2, y-2, canvas); - gl_vertex_window(x+2, y+2, canvas); - glEnd(); - glBegin(GL_LINE_STRIP); - gl_vertex_window(x+2, y-2, canvas); - gl_vertex_window(x-2, y+2, canvas); - glEnd(); - color++; - } +if(gy->symbol){ + switch(gy->symbol[i]){ + case GRAPH_SYMB_SQUARE: + glBegin(GL_LINE_STRIP); + gl_vertex_window(x-2, y-2, canvas); + gl_vertex_window(x+2, y-2, canvas); + gl_vertex_window(x+2, y+2, canvas); + gl_vertex_window(x-2, y+2, canvas); + gl_vertex_window(x-2, y-2, canvas); + glEnd(); + break; + case GRAPH_SYMB_CROSS: + glBegin(GL_LINE_STRIP); + gl_vertex_window(x-2, y-2, canvas); + gl_vertex_window(x+2, y+2, canvas); + glEnd(); + glBegin(GL_LINE_STRIP); + gl_vertex_window(x+2, y-2, canvas); + gl_vertex_window(x-2, y+2, canvas); + glEnd(); + break; + case GRAPH_SYMB_TRI_DN: + glBegin(GL_LINE_STRIP); + gl_vertex_window(x, y+3, canvas); + gl_vertex_window(x-3, y-3, canvas); + gl_vertex_window(x+3, y-3, canvas); + gl_vertex_window(x, y+3, canvas); + glEnd(); + break; + case GRAPH_SYMB_TRI_UP: + glBegin(GL_LINE_STRIP); + gl_vertex_window(x, y-3, canvas); + gl_vertex_window(x-3, y+3, canvas); + gl_vertex_window(x+3, y+3, canvas); + gl_vertex_window(x, y-3, canvas); + glEnd(); + break; + case GRAPH_SYMB_DIAM: + glBegin(GL_LINE_STRIP); + gl_vertex_window(x, y+5, canvas); + gl_vertex_window(x-5, y, canvas); + gl_vertex_window(x, y-5, canvas); + gl_vertex_window(x+5, y, canvas); + gl_vertex_window(x, y+5, canvas); + glEnd(); + break; + case GRAPH_SYMB_NONE: + default: + /*no symbol*/ + break; + } }else{ /*draw a default rectangle*/ glBegin(GL_LINE_STRIP); @@ -1078,19 +1102,49 @@ if(color!=NULL){ } if(oldx!=-1){ /*plot LINE data*/ - switch(graph->type){ - case GRAPH_USPEX: - case GRAPH_USPEX_2D: + switch(type){ + case GRAPH_IY_TYPE: + case GRAPH_XY_TYPE: + /* NEW: use line*/ + switch(line){ + case GRAPH_LINE_THICK: + glLineWidth(2.0); + case GRAPH_LINE_SINGLE: + glBegin(GL_LINE_STRIP); + gl_vertex_window(oldx, oldy-1, canvas); + gl_vertex_window(x, y-1, canvas); + glEnd(); + glLineWidth(1.0); + break; + case GRAPH_LINE_DASH: + glEnable(GL_LINE_STIPPLE); + glLineStipple(1,0xCCCC); + glBegin(GL_LINE_STRIP); + gl_vertex_window(oldx, oldy-1, canvas); + gl_vertex_window(x, y-1, canvas); + glEnd(); + glDisable(GL_LINE_STIPPLE); + case GRAPH_LINE_DOT: + glEnable(GL_LINE_STIPPLE); + glLineStipple(1,0xAAAA); + glBegin(GL_LINE_STRIP); + gl_vertex_window(oldx, oldy-1, canvas); + gl_vertex_window(x, y-1, canvas); + glEnd(); + glDisable(GL_LINE_STIPPLE); + break; + case GRAPH_LINE_NONE: + default: + break; + } + break; + case GRAPH_IX_TYPE: + case GRAPH_XX_TYPE: + /*not ready yet*/ break; case GRAPH_FREQUENCY: /*we should never reach here*/ break; - case GRAPH_USPEX_BEST: - glBegin(GL_LINE_STRIP); - gl_vertex_window(oldx,oldy-1,canvas); - gl_vertex_window(x,y-1,canvas); - glEnd(); - break; case GRAPH_DOS: case GRAPH_BAND: case GRAPH_REGULAR: @@ -1106,13 +1160,14 @@ if(oldx!=-1){ oldx=x; oldy=y; /*update index*/ - switch(graph->type){ + switch(type){ case GRAPH_FREQUENCY: case GRAPH_DOS: i++;/* ie twice ++ */ - case GRAPH_USPEX: - case GRAPH_USPEX_BEST: - case GRAPH_USPEX_2D: + case GRAPH_IY_TYPE: + case GRAPH_XY_TYPE: + case GRAPH_IX_TYPE: + case GRAPH_XX_TYPE: case GRAPH_BAND: case GRAPH_BANDOS: case GRAPH_REGULAR: @@ -1123,7 +1178,7 @@ if(oldx!=-1){ j++; } /*outside of loop*/ -switch (graph->type){ +switch (type){ /*plot add-axis*/ case GRAPH_DOS: /* need 0 y axis at Fermi level */ @@ -1176,71 +1231,88 @@ switch (graph->type){ gl_vertex_window(x, y-1, canvas); glEnd(); break; - case GRAPH_USPEX_BEST: - case GRAPH_USPEX_2D: - case GRAPH_USPEX: + case GRAPH_IY_TYPE: + case GRAPH_XY_TYPE: + case GRAPH_IX_TYPE: + case GRAPH_XX_TYPE: case GRAPH_FREQUENCY: case GRAPH_REGULAR: default: break; } - -/* draw peak selector */ -/*regular, frequency*/ - if (flag) { - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0x0303); - glColor3f(0.9, 0.7, 0.4); - glLineWidth(2.0); - glBegin(GL_LINES); - gl_vertex_window(sx, sy-10, canvas); - gl_vertex_window(sx, 3*gl_fontsize, canvas); - glEnd(); - - if (graph->select_label) - { - gint xoff; - - xoff = (gint) strlen(graph->select_label); - xoff *= gl_fontsize; - xoff /= 4; - gl_print_window(graph->select_label, sx-xoff, 2*gl_fontsize, canvas); - } - glDisable(GL_LINE_STIPPLE); - } -/* uspex, uspex_best */ - if(((graph->type==GRAPH_USPEX)||(graph->type==GRAPH_USPEX_BEST))&&(graph->select_label!=NULL)){ - xf = (gdouble) (graph->select+1) / (gdouble) (graph->size); - sx = ox + xf*dx; - yf = graph->select_2; - yf -= graph->ymin; - yf /= (graph->ymax - graph->ymin); - yf *= dy; - sy = (gint) yf; - sy *= -1; - sy += oy; - glEnable(GL_LINE_STIPPLE); - glLineStipple(1, 0x0303); - glColor3f(0.9, 0.7, 0.4); - glLineWidth(2.0); - /*horizontal*/ - glBegin(GL_LINES); - gl_vertex_window(ox, sy, canvas); - gl_vertex_window(sx, sy, canvas); - glEnd(); - /*vertical*/ - glBegin(GL_LINES); - gl_vertex_window(sx, sy, canvas); - gl_vertex_window(sx, -1*(gint)(dy)+oy, canvas); - glEnd(); - /*label*/ - gint xoff; - xoff = (gint) strlen(graph->select_label); - xoff *= gl_fontsize; - xoff /= 4; - gl_print_window(graph->select_label, sx-xoff, 2*gl_fontsize, canvas); - glDisable(GL_LINE_STIPPLE); - } +/* NEW - selector*/ + if((flag)||(graph->select_label!=NULL)){ + gint xoff; + list=graph->set_list; + glEnable(GL_LINE_STIPPLE); + glLineStipple(1, 0x0303); + glColor3f(0.9, 0.7, 0.4); + glLineWidth(2.0); + /*depend on graph->type ; TODO: manage changing types*/ + switch(graph->type){ + case GRAPH_IX_TYPE: + case GRAPH_XX_TYPE: + gx=(g_data_x *)list->data; + xf=gx->x[graph->select]; + yf=graph->select_2; + xf -= graph->xmin; + xf /= (graph->xmax - graph->xmin); + sx = ox + xf*dx; + yf -= graph->ymin; + yf /= (graph->ymax - graph->ymin); + yf *= dy; + sy = (gint) yf; + sy *= -1; + sy += oy; + /*horizontal*/ + glBegin(GL_LINES); + gl_vertex_window(ox, sy, canvas); + gl_vertex_window(sx, sy, canvas); + glEnd(); + /*vertical*/ + glBegin(GL_LINES); + gl_vertex_window(sx, sy, canvas); + gl_vertex_window(sx, -1*(gint)(dy)+oy, canvas); + glEnd(); + break; + case GRAPH_IY_TYPE: + case GRAPH_XY_TYPE: + gx=(g_data_x *)list->data; + xf=gx->x[graph->select]; + yf=graph->select_2; + xf -= graph->xmin; + xf /= (graph->xmax - graph->xmin); + sx = ox + xf*dx; + yf -= graph->ymin; + yf /= (graph->ymax - graph->ymin); + yf *= dy; + sy = (gint) yf; + sy *= -1; + sy += oy; + /*horizontal*/ + glBegin(GL_LINES); + gl_vertex_window(ox, sy, canvas); + gl_vertex_window(sx, sy, canvas); + glEnd(); + /*vertical*/ + glBegin(GL_LINES); + gl_vertex_window(sx, sy, canvas); + gl_vertex_window(sx, -1*(gint)(dy)+oy, canvas); + glEnd(); + break; + default: + glBegin(GL_LINES); + gl_vertex_window(sx, sy-10, canvas); + gl_vertex_window(sx, 3*gl_fontsize, canvas); + glEnd(); + } + /*label is always same (I think)*/ + xoff = (gint) strlen(graph->select_label); + xoff *= gl_fontsize; + xoff /= 4; + gl_print_window(graph->select_label, sx-xoff, 2*gl_fontsize, canvas); + glDisable(GL_LINE_STIPPLE); + } } /****************/ @@ -1254,9 +1326,10 @@ void graph_draw_1d(struct canvas_pak *canvas, struct graph_pak *graph) case GRAPH_BAND: case GRAPH_DOS: case GRAPH_BANDOS: - case GRAPH_USPEX: - case GRAPH_USPEX_BEST: - case GRAPH_USPEX_2D: + case GRAPH_IY_TYPE: + case GRAPH_XY_TYPE: + case GRAPH_IX_TYPE: + case GRAPH_XX_TYPE: graph_draw_new(canvas,graph); break; default: diff --git a/src/graph.h b/src/graph.h index 453e4dc..5c7b734 100644 --- a/src/graph.h +++ b/src/graph.h @@ -21,16 +21,47 @@ The GNU GPL can also be found at http://www.gnu.org */ typedef enum { - GRAPH_REGULAR=0,/*previous plain graph*/ - GRAPH_FREQUENCY,/*impulse graph for frequency*/ - GRAPH_BAND,/*kpoints/state energy graph */ - GRAPH_DOS,/*interleave e,dos plot*/ - GRAPH_BANDOS,/*dual BAND & DOS graph*/ - GRAPH_USPEX,/*point graph with selectable*/ - GRAPH_USPEX_BEST,/*linepoint graph with selectable*/ - GRAPH_USPEX_COMP,/*composition vs energy, point with selectable*/ - GRAPH_USPEX_2D,/*2D point graph with selectable*/ + GRAPH_REGULAR=0, /*previous plain graph*/ + GRAPH_FREQUENCY, /*impulse graph for frequency*/ + GRAPH_BAND, /*kpoints/state energy graph */ + GRAPH_DOS, /*interleave e,dos plot*/ + GRAPH_BANDOS, /*dual BAND & DOS graph*/ + /* NEW - graph: generic data types*/ + GRAPH_IY_TYPE, /*nx integer {x} + ny sets of {nx real y for all x}*/ + GRAPH_XY_TYPE, /*nx real {x} + ny sets of {nx real y for all x}*/ + GRAPH_IX_TYPE, /*nx integer {x} + nx sets of {ny real y for one x}*/ + GRAPH_XX_TYPE, /*nx real {x} + nx sets of {ny real y for one x}*/ } graph_type; +typedef enum { + /* NEW - graph: symbol shapes */ + GRAPH_SYMB_NONE=0, + GRAPH_SYMB_CROSS, + GRAPH_SYMB_SQUARE, + GRAPH_SYMB_TRI_DN, + GRAPH_SYMB_TRI_UP, + GRAPH_SYMB_DIAM, +} graph_symbol; +typedef enum { + /* NEW - graph: line shapes */ + GRAPH_LINE_NONE=0, /*no lines*/ + GRAPH_LINE_SINGLE, /*single line*/ + GRAPH_LINE_DASH, /*dashed line*/ + GRAPH_LINE_DOT, /*dotted line*/ + GRAPH_LINE_THICK, /*thick line*/ +} graph_line; +typedef struct { + gint x_size; /*size of the x array*/ + gdouble *x; /* -> x array*/ +} g_data_x; +typedef struct { + gint y_size; /*size of a y array*/ + gdouble *y; /* -> y array*/ + gint32 *idx; /*index up to 2,147,483,647 (<0 = missing structure)*/ + graph_type type; /* NEW - type can change for each set! */ + graph_symbol *symbol; /*symbol for each data*/ + graph_line line; /*one line type per set*/ + gdouble color; /*TODO graph set color*/ +} g_data_y; /*******************/ /* data structures */ /*******************/ @@ -44,7 +75,7 @@ struct graph_pak /* flags */ gint xlabel; gint ylabel; - graph_type type; + graph_type type; /*TODO eliminate this*/ /* graph layout */ gint xticks; gint yticks; @@ -54,17 +85,16 @@ struct graph_pak gdouble ymax; /* NB: all sets are required to be <= size */ gint size; - gchar *color;/*size array of "color"*/ - GSList *set_list;/*in case of 1D graph, set_list={x[,tag]} for 2D set_list={x,y[,tag]}*/ + GSList *set_list;/*in case of 1D graph, set_list={x[]} for other set_list={g_data_x,g_data_y[]}*/ /* peak selection */ gint select; - gdouble select_2;/*uspex peak selections require two index*/ + gdouble select_2;/*peak selections for 2D graph*/ gchar *select_label; }; gpointer graph_new(const gchar *, struct model_pak *); void graph_free_list(struct model_pak *); void graph_free(gpointer, struct model_pak *); -void graph_set_color(gchar *color,gpointer data); +void graph_set_color(gint size,gchar *color,gpointer data); void graph_add_data(gint, gdouble *, gdouble, gdouble, gpointer); void graph_add_borned_data(gint size,gdouble *x,gdouble x_min,gdouble x_max,gdouble y_min,gdouble y_max,gint type,gpointer data); void graph_frequency_select(gint x, gint y, struct model_pak *model); @@ -87,6 +117,13 @@ gdouble graph_xmax(gpointer); gdouble graph_ymin(gpointer); gdouble graph_ymax(gpointer); gdouble graph_wavelength(gpointer); +/* dat_graph interface */ +void dat_graph_set_x(g_data_x dx,gpointer pgraph); +void dat_graph_add_y(g_data_y dy,gpointer pgraph); +void dat_graph_set_limits(gdouble x_min,gdouble x_max,gdouble y_min,gdouble y_max,gpointer pgraph); +void dat_graph_set_type(graph_type type,gpointer pgraph); +void dat_graph_select(gint x, gint y, struct model_pak *model); + /* TODO - relocate */ gint anim_next_frame(struct model_pak *); diff --git a/src/gui_main.c b/src/gui_main.c index a9c8510..6419b14 100644 --- a/src/gui_main.c +++ b/src/gui_main.c @@ -129,8 +129,7 @@ if (data->graph_active) struct graph_pak *graph=(struct graph_pak *)data->graph_active; if(graph->type==GRAPH_REGULAR) diffract_select_peak(x, y, data); if(graph->type==GRAPH_FREQUENCY) graph_frequency_select(x, y, data); - if((graph->type==GRAPH_USPEX)||(graph->type==GRAPH_USPEX_BEST)) graph_uspex_select(x,y,data); - if(graph->type==GRAPH_USPEX_2D) graph_uspex_2d_select(x,y,data); + if((graph->type==GRAPH_IY_TYPE)||(GRAPH_XY_TYPE)||(GRAPH_IX_TYPE)||(GRAPH_XX_TYPE)) dat_graph_select(x,y,data); return(FALSE); } diff --git a/src/pak.h b/src/pak.h index e862acc..d22c177 100644 --- a/src/pak.h +++ b/src/pak.h @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. The GNU GPL can also be found at http://www.gnu.org */ -#define MAX_VALUE_SIZE 64 /*_BUG_OVHPA_1*/ +#define MAX_VALUE_SIZE 128 /*_BUG_OVHPA_1*/ /**********************************/ /* global unified rendering setup */ From 71da70c65a2c0c7d4d72e8e00dc2a1f8294ba922 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 5 Nov 2018 19:15:00 +0900 Subject: [PATCH 37/56] gui_uspex: uspex parameters I VER 10.1 --- src/file_uspex.c | 14 +- src/gui_defs.h | 7 + src/gui_uspex.c | 333 ++++++++++++++++++++++++++++++++++++----------- src/gui_uspex.h | 6 +- 4 files changed, 272 insertions(+), 88 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 344886a..1ceb7e7 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -679,7 +679,8 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); line = file_read_line(vf); continue; } - if (find_in_string("numSpecies",line) != NULL) { + if (find_in_string("numSpeci",line) != NULL) { +/*_BUG_ VER 10.1 EX26 has a typo (numSpecices instead of numSpecies)*/ vfpos=ftell(vf);/* flag */ g_free(line);line = file_read_line(vf);/*go next line*/ /*1st get the total number of lines*/ @@ -687,7 +688,8 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); do{ g_free(line);line = file_read_line(vf);/*go next line*/ _UC._var_nspecies++; - }while(find_in_string("EndNumSpecies",line) == NULL); + }while(find_in_string("EndNumSpeci",line) == NULL); +/*_BUG_ VER 10.1 EX26 has a consistent typo (EndNumSpecices instead of EndNumSpecies)*/ fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ g_free(line);/*FIX: _VALGRIND_BUG_*/ line = file_read_line(vf);/*first line of numSpecies*/ @@ -2977,13 +2979,7 @@ if((_UO.calc->_calctype_var)&&(_UC._nspecies>1)){ for(idx=0;idx<_UO.num_struct;idx++){ if(!_UO.ind[idx].have_data) continue; c_sum=0;for(ix=0;ix<_UO.calc->_nspecies;ix++) c_sum+=_UO.ind[idx].atoms[ix]; -if(c_sum==0) { - fprintf(stdout,"Something stupid is going on!\n"); - fprintf(stdout,"Ind %i atom: {",idx); - for(ix=0;ix<_UO.calc->_nspecies;ix++) fprintf(stdout,"%i ",_UO.ind[idx].atoms[ix]); - fprintf(stdout,"}\n"); - continue; -} + if(c_sum==0) continue;/*something stupid here!*/ compo=(gdouble)(_UO.ind[idx].atoms[species_index])/c_sum; if((compo>=1.0)||(compo<=0.0)) { continue;/*rejected*/ diff --git a/src/gui_defs.h b/src/gui_defs.h index 6f9974b..1bc929c 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -306,6 +306,13 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ gtk_table_attach_defaults(GTK_TABLE(table),button,l,r,t,b);\ g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ }while(0) +/*Create a new cell with: + * a delete button (button) connected on click to function (function).*/ +#define GUI_DELETE_BUTTON_TABLE(table,button,function,l,r,t,b) do{\ + button=gtk_button_new_from_stock(GTK_STOCK_DELETE);\ + gtk_table_attach_defaults(GTK_TABLE(table),button,l,r,t,b);\ + g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ +}while(0) /*Create a new cell with: * a boxed button of type APPLY connected on click to a function (function_1), * a boxed button of type DELETE connected on click to a function (function_2).*/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 9f1f53b..c576463 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -129,7 +129,7 @@ void gui_uspex_init(struct model_pak *model){ if((uspex_gui.calc.fracPerm==0)&&(uspex_gui.calc._nspecies>1)) uspex_gui.calc.fracPerm=0.1; if((uspex_gui.calc.fracRotMut==0)&&(uspex_gui.calc._calctype_mol)) uspex_gui.calc.fracRotMut=0.1; if((uspex_gui.calc.fracLatMut==0)&&(uspex_gui.calc.optRelaxType!=1)) uspex_gui.calc.fracLatMut=0.1; - if((uspex_gui.calc.howManySwaps==0)&&(uspex_gui.calc._nspecies>1)){ + if((uspex_gui.calc.howManySwaps==0)&&(uspex_gui.calc._nspecies>1)&&(uspex_gui.calc.numSpecies!=NULL)){ if(uspex_gui.calc.specificSwaps==NULL){ gint i,j; for(i=0;i<(uspex_gui.calc._nspecies-1);i++) @@ -316,8 +316,11 @@ void uspex_method_selected(GUI_OBJ *w){ uspex_gui.calc.calculationMethod = US_CM_VCNEB;break; case 3://PSO uspex_gui.calc.calculationMethod = US_CM_PSO;break; - case 4://UNKNOWN - default: + case 4://TPS + uspex_gui.calc.calculationMethod = US_CM_TPS;break; + case 5://MINHOP + uspex_gui.calc.calculationMethod = US_CM_MINHOP;break; + default://UNKNOWN uspex_gui.calc.calculationMethod = US_CM_UNKNOWN; } } @@ -328,60 +331,111 @@ void uspex_type_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch (index){ - case 1://301 + case 1://s300 + uspex_gui.calc.calculationType=US_CT_s300; + uspex_gui.calc._calctype_dim=3; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=TRUE; + break; + case 2://301 uspex_gui.calc.calculationType=US_CT_301; uspex_gui.calc._calctype_dim=3; uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=TRUE; + uspex_gui.calc._calctype_mag=FALSE; break; - case 2://310 + case 3://s301 + uspex_gui.calc.calculationType=US_CT_s301; + uspex_gui.calc._calctype_dim=3; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=TRUE; + uspex_gui.calc._calctype_mag=TRUE; + break; + case 4://310 uspex_gui.calc.calculationType=US_CT_310; uspex_gui.calc._calctype_dim=3; uspex_gui.calc._calctype_mol=TRUE; uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=FALSE; break; - case 3://311 + case 5://311 uspex_gui.calc.calculationType=US_CT_311; uspex_gui.calc._calctype_dim=3; uspex_gui.calc._calctype_mol=TRUE; uspex_gui.calc._calctype_var=TRUE; + uspex_gui.calc._calctype_mag=FALSE; break; - case 4://000 + case 6://000 uspex_gui.calc.calculationType=US_CT_000; uspex_gui.calc._calctype_dim=0; uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=FALSE; + break; + case 7://s000 + uspex_gui.calc.calculationType=US_CT_s000; + uspex_gui.calc._calctype_dim=0; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=TRUE; break; - case 5://110 + case 8://110 uspex_gui.calc.calculationType=US_CT_110; uspex_gui.calc._calctype_dim=1; uspex_gui.calc._calctype_mol=TRUE; uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=FALSE; break; - case 6://200 + case 9://200 uspex_gui.calc.calculationType=US_CT_200; uspex_gui.calc._calctype_dim=2; uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=FALSE; + break; + case 10://s200 + uspex_gui.calc.calculationType=US_CT_s200; + uspex_gui.calc._calctype_dim=2; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=TRUE; break; - case 7://201 + case 11://201 uspex_gui.calc.calculationType=US_CT_201; uspex_gui.calc._calctype_dim=2; uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=TRUE; + uspex_gui.calc._calctype_mag=FALSE; break; - case 8://-200 + case 12://s201 + uspex_gui.calc.calculationType=US_CT_s201; + uspex_gui.calc._calctype_dim=2; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=TRUE; + uspex_gui.calc._calctype_mag=TRUE; + break; + case 13://-200 uspex_gui.calc.calculationType=US_CT_m200; uspex_gui.calc._calctype_dim=-2; uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=FALSE; break; - case 0: + case 14://-s200 + uspex_gui.calc.calculationType=US_CT_sm200; + uspex_gui.calc._calctype_dim=-2; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=TRUE; + break; + case 0://300 default://bad value -> default 300 uspex_gui.calc.calculationType=US_CT_300; uspex_gui.calc._calctype_dim=3; uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mag=FALSE; } /*now update uspex_gui._calctype_dim, uspex_gui._calctype_mol, and uspex_gui._calctype_var*/ GUI_SPIN_SET(uspex_gui._calctype_dim,(gdouble)uspex_gui.calc._calctype_dim); @@ -389,6 +443,8 @@ void uspex_type_selected(GUI_OBJ *w){ else GUI_TOGGLE_OFF(uspex_gui._calctype_mol); if(uspex_gui.calc._calctype_var) GUI_TOGGLE_ON(uspex_gui._calctype_var); else GUI_TOGGLE_OFF(uspex_gui._calctype_var); + if(uspex_gui.calc._calctype_mag) GUI_TOGGLE_ON(uspex_gui._calctype_mag); + else GUI_TOGGLE_OFF(uspex_gui._calctype_mag); } /**************************/ /* update calculationType */ @@ -396,54 +452,77 @@ void uspex_type_selected(GUI_OBJ *w){ void _update_calculationType(){ gint i=0; switch(uspex_gui.calc._calctype_dim){ - case 3://300,301,310,311 + case 3://300,301,310,311 - VER 10.1 s300 s301 i=300; - if(uspex_gui.calc._calctype_mol) i+=10; - if(uspex_gui.calc._calctype_var) i+=1; break; - case 2://200,201 + case 2://200,201 - VER 10.1 s200 s201 i=200; - if(uspex_gui.calc._calctype_mol) uspex_gui.calc._calctype_mol=FALSE; - if(uspex_gui.calc._calctype_var) i+=1; + uspex_gui.calc._calctype_mol=FALSE; break; case 1://110 - i=110; - if(!uspex_gui.calc._calctype_mol) uspex_gui.calc._calctype_mol=TRUE; - if(uspex_gui.calc._calctype_var) uspex_gui.calc._calctype_var=FALSE; + i=100; + uspex_gui.calc._calctype_mag=FALSE; + uspex_gui.calc._calctype_mol=TRUE; + uspex_gui.calc._calctype_var=FALSE; break; - case 0://000 + case 0://000 - VER 10.1 s000 i=0; - if(uspex_gui.calc._calctype_mol) uspex_gui.calc._calctype_mol=FALSE; - if(uspex_gui.calc._calctype_var) uspex_gui.calc._calctype_var=FALSE; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; break; - case -2://-200 - i=-200; - if(uspex_gui.calc._calctype_mol) uspex_gui.calc._calctype_mol=FALSE; - if(uspex_gui.calc._calctype_var) uspex_gui.calc._calctype_var=FALSE; + case -2://-200 - VER 10.1 -s200 + i=200; + uspex_gui.calc._calctype_mol=FALSE; + uspex_gui.calc._calctype_var=FALSE; break; default://should not happen - i=300; + i=300;/*reset to default value*/ + uspex_gui.calc._calctype_mag=FALSE; uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=FALSE; } + if(uspex_gui.calc._calctype_mag) i+=1000; + if(uspex_gui.calc._calctype_mol) i+=10; + if(uspex_gui.calc._calctype_var) i+=1; + if(uspex_gui.calc._calctype_dim==-2) i*=-1; uspex_gui.calc.calculationType=i; + /*reset toogles*/ + if(uspex_gui.calc._calctype_mol) GUI_TOGGLE_ON(uspex_gui._calctype_mol); + else GUI_TOGGLE_OFF(uspex_gui._calctype_mol); + if(uspex_gui.calc._calctype_var) GUI_TOGGLE_ON(uspex_gui._calctype_var); + else GUI_TOGGLE_OFF(uspex_gui._calctype_var); + if(uspex_gui.calc._calctype_mag) GUI_TOGGLE_ON(uspex_gui._calctype_mag); + else GUI_TOGGLE_OFF(uspex_gui._calctype_mag); + /*reset select*/ switch(uspex_gui.calc.calculationType){ - case US_CT_301: + case US_CT_s300: GUI_COMBOBOX_SET(uspex_gui.calculationType,1);break; - case US_CT_310: + case US_CT_301: GUI_COMBOBOX_SET(uspex_gui.calculationType,2);break; - case US_CT_311: + case US_CT_s301: GUI_COMBOBOX_SET(uspex_gui.calculationType,3);break; - case US_CT_000: + case US_CT_310: GUI_COMBOBOX_SET(uspex_gui.calculationType,4);break; - case US_CT_110: + case US_CT_311: GUI_COMBOBOX_SET(uspex_gui.calculationType,5);break; - case US_CT_200: + case US_CT_000: GUI_COMBOBOX_SET(uspex_gui.calculationType,6);break; - case US_CT_201: + case US_CT_s000: GUI_COMBOBOX_SET(uspex_gui.calculationType,7);break; - case US_CT_m200: + case US_CT_110: GUI_COMBOBOX_SET(uspex_gui.calculationType,8);break; + case US_CT_200: + GUI_COMBOBOX_SET(uspex_gui.calculationType,9);break; + case US_CT_s200: + GUI_COMBOBOX_SET(uspex_gui.calculationType,10);break; + case US_CT_201: + GUI_COMBOBOX_SET(uspex_gui.calculationType,11);break; + case US_CT_s201: + GUI_COMBOBOX_SET(uspex_gui.calculationType,12);break; + case US_CT_m200: + GUI_COMBOBOX_SET(uspex_gui.calculationType,13);break; + case US_CT_sm200: + GUI_COMBOBOX_SET(uspex_gui.calculationType,14);break; case US_CT_300: default: GUI_COMBOBOX_SET(uspex_gui.calculationType,0); @@ -471,13 +550,25 @@ void spin_update_dim(){ /* toggle mol -> update calculation type */ /*****************************************/ void mol_toggle(void){ + gint dim=uspex_gui.calc._calctype_dim*100; + gint sgn; + if(dim<0) { + dim*=-1; + sgn=-1; + }else sgn=1; if(uspex_gui.calc._calctype_mol){ - if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10+1; - else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10; + if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = dim+10+1; + else uspex_gui.calc.calculationType = dim+10; }else{ - if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+1; - else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100; + if(uspex_gui.calc._calctype_mag){ + if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = 1000+dim+1; + else uspex_gui.calc.calculationType = 1000+dim; + }else{ + if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = dim+1; + else uspex_gui.calc.calculationType = dim; + } } + uspex_gui.calc.calculationType*=sgn; /*done, now update calculationType*/ _update_calculationType(); } @@ -485,13 +576,48 @@ void mol_toggle(void){ /* toggle var -> update calculation type */ /*****************************************/ void var_toggle(void){ + gint dim=uspex_gui.calc._calctype_dim*100; + gint sgn; + if(dim<0) { + dim*=-1; + sgn=-1; + }else sgn=1; if(uspex_gui.calc._calctype_var){ - if(uspex_gui.calc._calctype_mol) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10+1; - else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+1; + if(uspex_gui.calc._calctype_mol) uspex_gui.calc.calculationType = dim+10+1; + else if(uspex_gui.calc._calctype_mag) uspex_gui.calc.calculationType = 1000+dim+1; + else uspex_gui.calc.calculationType = dim+1; }else{ - if(uspex_gui.calc._calctype_mol) uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100+10; - else uspex_gui.calc.calculationType = uspex_gui.calc._calctype_dim*100; + if(uspex_gui.calc._calctype_mol) uspex_gui.calc.calculationType = dim+10; + else if(uspex_gui.calc._calctype_mag) uspex_gui.calc.calculationType = 1000+dim; + else uspex_gui.calc.calculationType = dim; } + uspex_gui.calc.calculationType*=sgn; + /*done, now update calculationType*/ + _update_calculationType(); +} +/*****************************************/ +/* mag_toggle -> update calculation type */ +/*****************************************/ +void mag_toggle(void){ + gint dim=uspex_gui.calc._calctype_dim*100; + gint sgn; + if(dim<0) { + dim*=-1; + sgn=-1; + }else sgn=1; + if(uspex_gui.calc._calctype_mag){ + if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = 1000+dim+1; + else uspex_gui.calc.calculationType = 1000+dim; + }else{ + if(uspex_gui.calc._calctype_mol){ + if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = dim+10+1; + else uspex_gui.calc.calculationType = dim+10; + }else{ + if(uspex_gui.calc._calctype_var) uspex_gui.calc.calculationType = dim+1; + else uspex_gui.calc.calculationType = dim; + } + } + uspex_gui.calc.calculationType*=sgn; /*done, now update calculationType*/ _update_calculationType(); } @@ -522,27 +648,33 @@ void uspex_optimization_selected(GUI_OBJ *w){ uspex_gui.calc.optType=US_OT_MAG;break; case 9://10 uspex_gui.calc.optType=US_OT_QE;break; - case 10://1101 + case 10://11 + uspex_gui.calc.optType=US_OT_2R;break; + case 11://14 + uspex_gui.calc.optType=US_OT_ZT;break; + case 12://17 + uspex_gui.calc.optType=US_OT_Fphon;break; + case 13://1101 uspex_gui.calc.optType=US_OT_BULK_M;break; - case 11://1102 + case 14://1102 uspex_gui.calc.optType=US_OT_SHEAR_M;break; - case 12://1103 + case 15://1103 uspex_gui.calc.optType=US_OT_YOUNG_M;break; - case 13://1104 + case 16://1104 uspex_gui.calc.optType=US_OT_POISSON;break; - case 14://1105 + case 17://1105 uspex_gui.calc.optType=US_OT_PUGH_R;break; - case 15://1106 + case 18://1106 uspex_gui.calc.optType=US_OT_VICKERS_H;break; - case 16://1107 + case 19://1107 uspex_gui.calc.optType=US_OT_FRACTURE;break; - case 17://1108 + case 20://1108 uspex_gui.calc.optType=US_OT_DEBYE_T;break; - case 18://1109 + case 21://1109 uspex_gui.calc.optType=US_OT_SOUND_V;break; - case 19://1110 + case 22://1110 uspex_gui.calc.optType=US_OT_SWAVE_V;break; - case 20://1111 + case 23://1111 uspex_gui.calc.optType=US_OT_PWAVE_V;break; default: uspex_gui.calc.optType=US_OT_UNKNOWN; @@ -772,6 +904,16 @@ void remove_bonds(){ GUI_COMBOBOX_SET(uspex_gui.goodBonds,index-1); g_free(text); } +/**********************/ +/* toggle new_optType */ +/**********************/ +void opt_toggle(){ + if(uspex_gui.have_new_opt){ + GUI_UNLOCK(uspex_gui.new_optType); + }else{ + GUI_LOCK(uspex_gui.new_optType); + } +} /******************/ /* toggle auto_SV */ /******************/ @@ -1411,6 +1553,14 @@ void gui_uspex_dialog(void){ init_uspex_parameters(&(uspex_gui.calc)); gui_uspex_init(data); } +/*bailout process*/ + +if(uspex_gui.calc.numSpecies==NULL){ + title=g_strdup("USPEX model is missing numSpecies information!\n"); + gui_text_show(ERROR,title); + g_free(title); +} + /* dialog setup */ title = g_strdup_printf("USPEX: %s", data->basename); dialog = dialog_request(CUSPEX, title, NULL, uspex_cleanup,data); @@ -1450,58 +1600,74 @@ GUI_TOOLTIP(uspex_gui.file_entry,"Use the previous result of a USPEX calculation /* --- Type & System */ GUI_FRAME_NOTE(page,frame,"Type & System"); /* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,6,4); + GUI_TABLE_FRAME(frame,table,6,7); /* 1st line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.calculationMethod,"calcMethod: ",0,1,0,1); + GUI_COMBOBOX_TABLE(table,uspex_gui.calculationMethod,"Method: ",0,1,0,1); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"USPEX"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"META"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"VCNEB"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"PSO"); + GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"TPS"); + GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"MINHOP"); GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: USPEX\nSet the method of calculation."); - GUI_COMBOBOX_TABLE(table,uspex_gui.calculationType,"calcType: ",1,3,0,1); + GUI_COMBOBOX_TABLE(table,uspex_gui.calculationType,"Type: ",1,2,0,1); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"300"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s300"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"301"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s301"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"310"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"311"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"000"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s000"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"110"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"200"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s200"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"201"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s201"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"-200"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"-s200"); GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationType: Ch. 4.1 DEFAULT: 300\nSets the dimensionality, molecularity, and variability\nof the calculation, can also be set individually.\n(311) and (110) calculations may not be supported."); - GUI_SPIN_TABLE(table,uspex_gui._calctype_dim,uspex_gui._dim,spin_update_dim,"DIM",3,4,0,1); + GUI_SPIN_TABLE(table,uspex_gui._calctype_dim,uspex_gui._dim,spin_update_dim,"DIM",2,3,0,1); GUI_SPIN_RANGE(uspex_gui._calctype_dim,-2.,3.); GUI_TOOLTIP(uspex_gui._calctype_dim,"Set the dimension of the system.\n3, 2, 1, and 0 are equilvalent to 3D, 2D, 1D, and 0D.\n-2 correspond to 2D crystals."); - GUI_CHECK_TABLE(table,uspex_gui._calctype_mol,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",4,5,0,1); + GUI_CHECK_TABLE(table,uspex_gui._calctype_mol,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",3,4,0,1); GUI_TOOLTIP(uspex_gui._calctype_mol,"Set the molecularity of the system."); - GUI_CHECK_TABLE(table,uspex_gui._calctype_var,uspex_gui.calc._calctype_var,var_toggle,"VAR",5,6,0,1); + GUI_CHECK_TABLE(table,uspex_gui._calctype_var,uspex_gui.calc._calctype_var,var_toggle,"VAR",4,5,0,1); GUI_TOOLTIP(uspex_gui._calctype_var,"Set the variability of chemical composition."); + GUI_CHECK_TABLE(table,uspex_gui._calctype_mag,uspex_gui.calc._calctype_mag,mag_toggle,"MAG",5,6,0,1); +GUI_TOOLTIP(uspex_gui._calctype_var,"Set a magnetic calculation."); /* 2nd line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.atomType,"atomType:",0,1,1,2); + GUI_COMBOBOX_TABLE(table,uspex_gui.atomType,"atomType:",0,2,1,3);/*multiline*/ GUI_COMBOBOX_ADD(uspex_gui.atomType,"ADD ATOMTYPE"); GUI_TOOLTIP(uspex_gui.atomType,"atomType: Ch. 4.1 DEFAULT: none\nThis list regroups several tags:\natomType, numSpecies, and valences."); uspex_gui._tmp_atom_typ=0;uspex_gui._tmp_atom_num=0;uspex_gui._tmp_atom_val=0; strcpy(uspex_gui._tmp_atom_sym,elements[uspex_gui._tmp_atom_typ].symbol); - GUI_ENTRY_TABLE(table,uspex_gui._atom_sym,uspex_gui._tmp_atom_sym,"%s","@Sym:",1,2,1,2); + GUI_ENTRY_TABLE(table,uspex_gui._atom_sym,uspex_gui._tmp_atom_sym,"%s","@Sym:",2,3,1,2); GUI_TOOLTIP(uspex_gui._atom_sym,"atomSym: - DEFAULT: none\nAtomic symbol of current species."); - GUI_ENTRY_TABLE(table,uspex_gui._atom_typ,uspex_gui._tmp_atom_typ,"%3i","@Typ:",2,3,1,2); + GUI_ENTRY_TABLE(table,uspex_gui._atom_typ,uspex_gui._tmp_atom_typ,"%3i","@Z:",3,5,1,2); GUI_TOOLTIP(uspex_gui._atom_typ,"atomTyp: - DEFAULT: none\nAtomic number of current species."); - GUI_ENTRY_TABLE(table,uspex_gui._atom_num,uspex_gui._tmp_atom_num,"%3i","@Num:",3,4,1,2); + GUI_APPLY_BUTTON_TABLE(table,button,apply_atom,5,6,1,2); +/*3rd line*/ + /*col 0-2 is multiline*/ + GUI_ENTRY_TABLE(table,uspex_gui._atom_num,uspex_gui._tmp_atom_num,"%3i","@Num:",2,3,2,3); GUI_TOOLTIP(uspex_gui._atom_num,"atomNum: - DEFAULT: none\nNumber of atoms in current species."); - GUI_ENTRY_TABLE(table,uspex_gui._atom_val,uspex_gui._tmp_atom_val,"%3i","@Val:",4,5,1,2); + GUI_ENTRY_TABLE(table,uspex_gui._atom_val,uspex_gui._tmp_atom_val,"%3i","@Val:",3,5,2,3); GUI_TOOLTIP(uspex_gui._atom_val,"atomVal: - DEFAULT: auto\nValence of the current species.\nAutomatically determined if zero."); - GUI_2BUTTONS_TABLE(table,apply_atom,remove_atom,5,6,1,2); -/* 3rd line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.goodBonds,"goodBonds:",0,1,2,3); + GUI_DELETE_BUTTON_TABLE(table,button,remove_atom,5,6,2,3); +/* 4th line */ + GUI_COMBOBOX_TABLE(table,uspex_gui.goodBonds,"goodBonds:",0,2,3,5);/*multiline*/ GUI_COMBOBOX_ADD(uspex_gui.goodBonds,"ADD GOODBOND"); GUI_TOOLTIP(uspex_gui.goodBonds,"goodBonds: Ch. 4.1 DEFAULT: auto\nSet the minimum distance at which a bond is considered."); - GUI_TEXT_TABLE(table,uspex_gui._bond_d,uspex_gui._tmp_bond_d,"Bonds: ",1,4,2,3); + GUI_TEXT_TABLE(table,uspex_gui._bond_d,uspex_gui._tmp_bond_d,"Bonds: ",2,5,3,4); GUI_TOOLTIP(uspex_gui._bond_d,"Minimum bond distance between selected and others species."); - GUI_CHECK_TABLE(table,button,uspex_gui.auto_bonds,auto_bond_toggle,"AUTO_BONDS",4,5,2,3); + GUI_APPLY_BUTTON_TABLE(table,button,apply_bonds,5,6,3,4); +/* 5th line */ + /*col 0-2 is multiline*/ + GUI_CHECK_TABLE(table,button,uspex_gui.auto_bonds,auto_bond_toggle,"AUTO_BONDS",4,5,4,5); GUI_TOOLTIP(button,"Automatically determine bonds (recommended)."); - GUI_2BUTTONS_TABLE(table,apply_bonds,remove_bonds,5,6,2,3); -/* 4th line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,3,3,4); + GUI_DELETE_BUTTON_TABLE(table,button,remove_bonds,5,6,4,5); +/* 6th line */ + GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,2,5,7);/*multiline*/ GUI_COMBOBOX_ADD(uspex_gui.optType,"1: MIN Enthalpy (stable phases)"); GUI_COMBOBOX_ADD(uspex_gui.optType,"2: MIN Volume (densest structure)"); GUI_COMBOBOX_ADD(uspex_gui.optType,"3: MAX Hardness (hardest phase)"); @@ -1512,6 +1678,9 @@ GUI_TOOLTIP(button,"Automatically determine bonds (recommended)."); GUI_COMBOBOX_ADD(uspex_gui.optType,"8: MAX electric energy storage capacity"); GUI_COMBOBOX_ADD(uspex_gui.optType,"9: MAX Magnetization"); GUI_COMBOBOX_ADD(uspex_gui.optType,"10: MAX Structure quasientropy"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"11: MAX? L/H eigenvalue difference of refractive index"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"14: MAX? ZT thermoelectric figure of merit"); + GUI_COMBOBOX_ADD(uspex_gui.optType,"17: MAX? free energy at finite temperature"); GUI_COMBOBOX_ADD(uspex_gui.optType,"1101: MAX Bulk modulus"); GUI_COMBOBOX_ADD(uspex_gui.optType,"1102: MAX Shear modulus"); GUI_COMBOBOX_ADD(uspex_gui.optType,"1103: MAX Young modulus"); @@ -1524,11 +1693,17 @@ GUI_TOOLTIP(button,"Automatically determine bonds (recommended)."); GUI_COMBOBOX_ADD(uspex_gui.optType,"1110: MAX S-wave velocity"); GUI_COMBOBOX_ADD(uspex_gui.optType,"1111: MAX P-wave velocity"); GUI_TOOLTIP(uspex_gui.optType,"optType: Ch. 4.1 DEFAULT: 1(Enthalpy)\nSelect the properties to optimize."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.anti_opt,NULL,"ANTI-OPT",3,4,3,4);/*not calling anything*/ + GUI_TEXT_TABLE(table,uspex_gui.new_optType,uspex_gui._tmp_new_optType,"NEW optType: ",2,5,5,6); +GUI_TOOLTIP(uspex_gui.optType,"optType: Ch. 4.1 DEFAULT: MIN_enthalpy\nSelect the properties to optimize in the new\nVER 10.1 USPEX format."); + GUI_CHECK_TABLE(table,button,uspex_gui.have_new_opt,opt_toggle,"NEW",5,6,5,6); +GUI_TOOLTIP(button,"Use the VER 10.1 optType format.\nMandatory for multiobjective optimization."); +/* 7th line */ + /*col 0-2 is multiline*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.anti_opt,NULL,"ANTI-OPT",2,3,6,7);/*not calling anything*/ GUI_TOOLTIP(button,"anti-opt: - DEFAULT: FALSE\nIf set REVERSE the direction of optimization.\ni.e. MIN -> MAX & MAX -> MIN"); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMolecs",4,5,3,4);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMolecs",3,4,6,7);/*not calling anything*/ GUI_TOOLTIP(button,"checkMolecules: Ch. 4.1 DEFAULT: TRUE\nCheck and discard broken/merged molecules."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckConnect",5,6,3,4);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckConnect",4,5,6,7);/*not calling anything*/ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardness and add connectivity in softmutation."); /* initialize */ GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); @@ -1540,8 +1715,10 @@ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardnes GUI_SPIN_SET(uspex_gui._calctype_dim,(gdouble) uspex_gui.calc._calctype_dim); mol_toggle(); var_toggle(); + mag_toggle(); GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,goodBonds_selected); auto_bond_toggle(); + opt_toggle(); /* --- end frame */ /* --- Population */ GUI_FRAME_NOTE(page,frame,"Population"); diff --git a/src/gui_uspex.h b/src/gui_uspex.h index bc83ded..9b47f4b 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -55,14 +55,18 @@ struct uspex_calc_gui{ gdouble _dim;/*absurd spin on double*/ GUI_OBJ *_calctype_mol; GUI_OBJ *_calctype_var; + GUI_OBJ *_calctype_mag; /*VER 10.1*/ GUI_OBJ *optType; + gboolean have_new_opt; /*VER 10.1*/ + GUI_OBJ *new_optType; /*VER 10.1*/ + gchar *_tmp_new_optType; /*VER 10.1*/ /*atoms definition: apply/remove*/ GUI_OBJ *atomType; GUI_OBJ *_atom_sym; GUI_OBJ *_atom_typ; GUI_OBJ *_atom_num; GUI_OBJ *_atom_val; - /*temporary value*/ + /*temporary values*/ gchar _tmp_atom_sym[3]; gint _tmp_atom_typ; gint _tmp_atom_num; From 1cbb289087846560916ddf549004cf3d0833ffe2 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 7 Nov 2018 15:31:33 +0900 Subject: [PATCH 38/56] gui_uspex: uspex parameters II VER 10.1 --- src/file_uspex.c | 1 + src/gui_defs.h | 39 ++-- src/gui_uspex.c | 465 ++++++++++++++++++++++++----------------------- src/gui_uspex.h | 36 +++- 4 files changed, 297 insertions(+), 244 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 1ceb7e7..08b7960 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -120,6 +120,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.minVectorLength=0.; _UC.IonDistances=NULL; _UC.constraint_enhancement=TRUE; + _UC._nmolecules=0; _UC.MolCenters=NULL; _UC.Latticevalues=NULL; _UC.splitInto=NULL; diff --git a/src/gui_defs.h b/src/gui_defs.h index 1bc929c..12cb4b3 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -131,10 +131,16 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ frame = gtk_frame_new(caption);\ gtk_box_pack_start(GTK_BOX(page),frame,FALSE,FALSE,0);\ }while(0) +/*create a new table (table) in a notebook page (page).*/ +#define GUI_TABLE_NOTE(page,table,row,col) do{\ + table=gtk_table_new(row, col, FALSE);\ + gtk_box_pack_start(GTK_BOX(page),table,TRUE,TRUE,0);\ +}while(0) /*Connect a switch-page even of a notebook (notebook) to a function (function) passing data (data).*/ #define GUI_PAGE_CHANGE(notebook,function,data) do{\ g_signal_connect(GTK_NOTEBOOK(notebook),"switch-page",GTK_SIGNAL_FUNC(function),data);\ }while(0) +/*return page number*/ #define GUI_NOTE_PAGE_NUMBER(notebook,number) do{\ number = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));\ }while(0) @@ -162,11 +168,18 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ /* TABLE INTERFACE: */ /* all of the *_TABLE() defines set a new table cell @l,r,t,b in table (table).*/ /************************************************************************************/ +#define _ATTACH_TABLE(table,widget,l,r,t,b) gtk_table_attach_defaults(GTK_TABLE(table),widget,l,r,t,b) +//gtk_table_attach(GTK_TABLE(table),widget,l,r,t,b,GTK_FILL,GTK_FILL,0,0) /*Create a new cell with: * a label with text ("text")*/ #define GUI_LABEL_TABLE(table,text,l,r,t,b) do{\ GtkWidget *_label = gtk_label_new(text);\ - gtk_table_attach_defaults(GTK_TABLE(table),_label,l,r,t,b);\ + _ATTACH_TABLE(table,_label,l,r,t,b);\ +}while(0) +/*Create a new frame with the text ("text")*/ +#define GUI_FRAME_TABLE(table,text,l,r,t,b) do{\ + GtkWidget *_frame = gtk_frame_new(text);\ + _ATTACH_TABLE(table,_frame,l,r,t,b);\ }while(0) /*Create a new cell with: * a boxed label (created with GUI_LABEL_BOX) with text ("caption"), @@ -176,7 +189,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ GUI_LABEL_BOX(_hbox,_label,caption);\ GUI_TEXT_ENTRY(_hbox,entry,value,TRUE);\ - gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ + _ATTACH_TABLE(table,_hbox,l,r,t,b);\ }while(0) /*Create a new cell with: * a boxed label (created with GUI_LABEL_BOX) with text ("caption"), @@ -189,14 +202,14 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ GUI_LABEL_BOX(_hbox,_label,caption);\ GUI_NEW_SEPARATOR(_hbox,_separator);\ GUI_ENTRY(_hbox,entry,value,format,8);\ - gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ + _ATTACH_TABLE(table,_hbox,l,r,t,b);\ }while(0) /*Create a new cell with: * a new check button (check) with an initial value (value) connected to function (function) with text ("caption").*/ #define GUI_CHECK_TABLE(table,check,value,function,caption,l,r,t,b) do{\ GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ check = gui_direct_check(caption,&(value),function,NULL,_hbox);\ - gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ + _ATTACH_TABLE(table,_hbox,l,r,t,b);\ }while(0) /*Create a new cell with: * a boxed label (created with GUI_LABEL_BOX) with text ("caption"), @@ -212,7 +225,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ GUI_LABEL_BOX(_hbox,_label,caption);\ GUI_NEW_SEPARATOR(_hbox,_separator);\ GUI_REG_COMBO(hbox,combo,list,default_text,function);\ - gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ + _ATTACH_TABLE(table,_hbox,l,r,t,b);\ }while(0) /*Create a new cell with: * a separator (not boxed!). @@ -232,7 +245,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ combobox=gtk_combo_box_text_new_with_entry();\ gtk_entry_set_editable(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(combobox))),FALSE);\ gtk_box_pack_start(GTK_BOX(_hbox),combobox,TRUE,TRUE,0);\ - gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ + _ATTACH_TABLE(table,_hbox,l,r,t,b);\ }while(0) /*Add a new element with text ("text") in the combobox (combobox). * This have to be called AFTER GUI_COMBOBOX.*/ @@ -282,7 +295,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_SPIN_TABLE(table,spin,value,function,caption,l,r,t,b) do{\ GtkWidget *_hbox = gtk_hbox_new(FALSE, 0);\ spin = gui_direct_spin(caption,&(value),1.0,100.0,1.0,function,NULL,_hbox);\ - gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ + _ATTACH_TABLE(table,_hbox,l,r,t,b);\ }while(0) /*Set spin (spin) within range [min,max] (min,max).*/ #define GUI_SPIN_RANGE(spin,min,max) do{\ @@ -296,21 +309,21 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ * an open button (button) connected on click to function (function).*/ #define GUI_OPEN_BUTTON_TABLE(table,button,function,l,r,t,b) do{\ button=gtk_button_new_from_stock(GTK_STOCK_OPEN);\ - gtk_table_attach_defaults(GTK_TABLE(table),button,l,r,t,b);\ + _ATTACH_TABLE(table,button,l,r,t,b);\ g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ }while(0) /*Create a new cell with: * an apply button (button) connected on click to function (function).*/ #define GUI_APPLY_BUTTON_TABLE(table,button,function,l,r,t,b) do{\ button=gtk_button_new_from_stock(GTK_STOCK_APPLY);\ - gtk_table_attach_defaults(GTK_TABLE(table),button,l,r,t,b);\ + _ATTACH_TABLE(table,button,l,r,t,b);\ g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ }while(0) /*Create a new cell with: * a delete button (button) connected on click to function (function).*/ #define GUI_DELETE_BUTTON_TABLE(table,button,function,l,r,t,b) do{\ button=gtk_button_new_from_stock(GTK_STOCK_DELETE);\ - gtk_table_attach_defaults(GTK_TABLE(table),button,l,r,t,b);\ + _ATTACH_TABLE(table,button,l,r,t,b);\ g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ }while(0) /*Create a new cell with: @@ -322,7 +335,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ GUI_NEW_SEPARATOR(_hbox,_sep);\ gui_stock_button(GTK_STOCK_APPLY,function_1,NULL,_hbox);\ gui_stock_button(GTK_STOCK_DELETE,function_2,NULL,_hbox);\ - gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ + _ATTACH_TABLE(table,_hbox,l,r,t,b);\ }while(0) /*left aligned labels*/ /*Create a new cell with: @@ -335,7 +348,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ GtkWidget *_label = gtk_label_new(caption);\ gtk_box_pack_start(GTK_BOX(_hbox),_label,FALSE,FALSE,0);\ GUI_NEW_SEPARATOR(_hbox,_separator);\ - gtk_table_attach_defaults(GTK_TABLE(table),_hbox,l,r,t,b);\ + _ATTACH_TABLE(table,_hbox,l,r,t,b);\ }while(0) /*Create a new cell with: * a radio button (radio_1) with caption ("caption_1") connected to function (pointer_1) @@ -345,7 +358,7 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ new_radio_group(0,_vbox,FF);\ radio_1 = add_radio_button(caption_1,(gpointer)pointer_1,NULL);\ radio_2 = add_radio_button(caption_2,(gpointer)pointer_2,NULL);\ - gtk_table_attach_defaults(GTK_TABLE(table),_vbox,l,r,t,b);\ + _ATTACH_TABLE(table,_vbox,l,r,t,b);\ }while(0) /********************/ /* GENERAL COMMANDS */ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index c576463..2eeb5df 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -62,7 +62,19 @@ struct uspex_calc_gui uspex_gui; /*************************/ void gui_uspex_init(struct model_pak *model){ gint idx; + gchar *line; uspex_gui.cur_page=USPEX_PAGE_SET_I; + /*prepare local values*/ + uspex_gui._tmp_atom_typ=0;uspex_gui._tmp_atom_num=0;uspex_gui._tmp_atom_val=0; + strcpy(uspex_gui._tmp_atom_sym,elements[uspex_gui._tmp_atom_typ].symbol); + + uspex_gui._tmp_specificTrans=NULL; + if(uspex_gui.calc._nspetrans>0) { + line=g_strdup(""); + for(idx=0;idx SET-I */ -/*-----------------*/ - GUI_PAGE_NOTE(notebook,page,"SET-I"); +/*------------------*/ +/* page 1 -> SYSTEM */ +/*------------------*/ + GUI_PAGE_NOTE(notebook,page,"SYSTEM"); +/* create a table in the page*/ + GUI_TABLE_NOTE(page,table,17,4); /* --- Type & System */ - GUI_FRAME_NOTE(page,frame,"Type & System"); -/* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,6,7); -/* 1st line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.calculationMethod,"Method: ",0,1,0,1); + GUI_LABEL_TABLE(table,"Type & System",0,4,0,1); +/* line 1 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.calculationMethod,"Method: ",0,1,1,2);/*multiline*/ GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"USPEX"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"META"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"VCNEB"); @@ -1610,7 +1586,7 @@ GUI_TOOLTIP(uspex_gui.file_entry,"Use the previous result of a USPEX calculation GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"TPS"); GUI_COMBOBOX_ADD(uspex_gui.calculationMethod,"MINHOP"); GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: USPEX\nSet the method of calculation."); - GUI_COMBOBOX_TABLE(table,uspex_gui.calculationType,"Type: ",1,2,0,1); + GUI_COMBOBOX_TABLE(table,uspex_gui.calculationType,"Type: ",1,3,1,2); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"300"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s300"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"301"); @@ -1626,48 +1602,49 @@ GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: USP GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s201"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"-200"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"-s200"); -GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationType: Ch. 4.1 DEFAULT: 300\nSets the dimensionality, molecularity, and variability\nof the calculation, can also be set individually.\n(311) and (110) calculations may not be supported."); - GUI_SPIN_TABLE(table,uspex_gui._calctype_dim,uspex_gui._dim,spin_update_dim,"DIM",2,3,0,1); +GUI_TOOLTIP(uspex_gui.calculationType,"calculationType: Ch. 4.1 DEFAULT: 300\nSets the dimensionality, molecularity, and variability\nof the calculation, can also be set individually.\n(311) and (110) calculations may not be supported."); + GUI_CHECK_TABLE(table,uspex_gui._calctype_mag,uspex_gui.calc._calctype_mag,mag_toggle,"MAG",3,4,1,2); +GUI_TOOLTIP(uspex_gui._calctype_mag,"Set a magnetic calculation."); +/* line 2 */ + /*col 1: empty*/ + GUI_SPIN_TABLE(table,uspex_gui._calctype_dim,uspex_gui._dim,spin_update_dim,"DIM",1,2,2,3); GUI_SPIN_RANGE(uspex_gui._calctype_dim,-2.,3.); GUI_TOOLTIP(uspex_gui._calctype_dim,"Set the dimension of the system.\n3, 2, 1, and 0 are equilvalent to 3D, 2D, 1D, and 0D.\n-2 correspond to 2D crystals."); - GUI_CHECK_TABLE(table,uspex_gui._calctype_mol,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",3,4,0,1); + GUI_CHECK_TABLE(table,uspex_gui._calctype_mol,uspex_gui.calc._calctype_mol,mol_toggle,"MOL",2,3,2,3); GUI_TOOLTIP(uspex_gui._calctype_mol,"Set the molecularity of the system."); - GUI_CHECK_TABLE(table,uspex_gui._calctype_var,uspex_gui.calc._calctype_var,var_toggle,"VAR",4,5,0,1); + GUI_CHECK_TABLE(table,uspex_gui._calctype_var,uspex_gui.calc._calctype_var,var_toggle,"VAR",3,4,2,3); GUI_TOOLTIP(uspex_gui._calctype_var,"Set the variability of chemical composition."); - GUI_CHECK_TABLE(table,uspex_gui._calctype_mag,uspex_gui.calc._calctype_mag,mag_toggle,"MAG",5,6,0,1); -GUI_TOOLTIP(uspex_gui._calctype_var,"Set a magnetic calculation."); -/* 2nd line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.atomType,"atomType:",0,2,1,3);/*multiline*/ +/* line 3 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.atomType,"atomType:",0,1,3,4);/*multiline*/ GUI_COMBOBOX_ADD(uspex_gui.atomType,"ADD ATOMTYPE"); GUI_TOOLTIP(uspex_gui.atomType,"atomType: Ch. 4.1 DEFAULT: none\nThis list regroups several tags:\natomType, numSpecies, and valences."); - uspex_gui._tmp_atom_typ=0;uspex_gui._tmp_atom_num=0;uspex_gui._tmp_atom_val=0; - strcpy(uspex_gui._tmp_atom_sym,elements[uspex_gui._tmp_atom_typ].symbol); - GUI_ENTRY_TABLE(table,uspex_gui._atom_sym,uspex_gui._tmp_atom_sym,"%s","@Sym:",2,3,1,2); + GUI_ENTRY_TABLE(table,uspex_gui._atom_sym,uspex_gui._tmp_atom_sym,"%s","@Sym:",1,2,3,4); GUI_TOOLTIP(uspex_gui._atom_sym,"atomSym: - DEFAULT: none\nAtomic symbol of current species."); - GUI_ENTRY_TABLE(table,uspex_gui._atom_typ,uspex_gui._tmp_atom_typ,"%3i","@Z:",3,5,1,2); + GUI_ENTRY_TABLE(table,uspex_gui._atom_typ,uspex_gui._tmp_atom_typ,"%3i","@Z:",2,3,3,4); GUI_TOOLTIP(uspex_gui._atom_typ,"atomTyp: - DEFAULT: none\nAtomic number of current species."); - GUI_APPLY_BUTTON_TABLE(table,button,apply_atom,5,6,1,2); -/*3rd line*/ - /*col 0-2 is multiline*/ - GUI_ENTRY_TABLE(table,uspex_gui._atom_num,uspex_gui._tmp_atom_num,"%3i","@Num:",2,3,2,3); + GUI_APPLY_BUTTON_TABLE(table,button,apply_atom,3,4,3,4); +/* line 4 */ + /*col 1: empty*/ + GUI_ENTRY_TABLE(table,uspex_gui._atom_num,uspex_gui._tmp_atom_num,"%3i","@Num:",1,2,4,5); GUI_TOOLTIP(uspex_gui._atom_num,"atomNum: - DEFAULT: none\nNumber of atoms in current species."); - GUI_ENTRY_TABLE(table,uspex_gui._atom_val,uspex_gui._tmp_atom_val,"%3i","@Val:",3,5,2,3); + GUI_ENTRY_TABLE(table,uspex_gui._atom_val,uspex_gui._tmp_atom_val,"%3i","@Val:",2,3,4,5); GUI_TOOLTIP(uspex_gui._atom_val,"atomVal: - DEFAULT: auto\nValence of the current species.\nAutomatically determined if zero."); - GUI_DELETE_BUTTON_TABLE(table,button,remove_atom,5,6,2,3); -/* 4th line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.goodBonds,"goodBonds:",0,2,3,5);/*multiline*/ + GUI_DELETE_BUTTON_TABLE(table,button,remove_atom,3,4,4,5); +/* line 5 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.goodBonds,"goodBonds:",0,1,5,6);/*multiline*/ GUI_COMBOBOX_ADD(uspex_gui.goodBonds,"ADD GOODBOND"); GUI_TOOLTIP(uspex_gui.goodBonds,"goodBonds: Ch. 4.1 DEFAULT: auto\nSet the minimum distance at which a bond is considered."); - GUI_TEXT_TABLE(table,uspex_gui._bond_d,uspex_gui._tmp_bond_d,"Bonds: ",2,5,3,4); + GUI_TEXT_TABLE(table,uspex_gui._bond_d,uspex_gui._tmp_bond_d,"Bonds: ",1,3,5,6); GUI_TOOLTIP(uspex_gui._bond_d,"Minimum bond distance between selected and others species."); - GUI_APPLY_BUTTON_TABLE(table,button,apply_bonds,5,6,3,4); -/* 5th line */ - /*col 0-2 is multiline*/ - GUI_CHECK_TABLE(table,button,uspex_gui.auto_bonds,auto_bond_toggle,"AUTO_BONDS",4,5,4,5); + GUI_APPLY_BUTTON_TABLE(table,button,apply_bonds,3,4,5,6); +/* line 6 */ + /*col 1: empty*/ + /*col 2: empty*/ + GUI_CHECK_TABLE(table,button,uspex_gui.auto_bonds,auto_bond_toggle,"AUTO_BONDS",2,3,6,7); GUI_TOOLTIP(button,"Automatically determine bonds (recommended)."); - GUI_DELETE_BUTTON_TABLE(table,button,remove_bonds,5,6,4,5); -/* 6th line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,2,5,7);/*multiline*/ + GUI_DELETE_BUTTON_TABLE(table,button,remove_bonds,3,4,6,7); +/* line 7 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.optType,"optType:",0,1,7,8);/*multiline*/ GUI_COMBOBOX_ADD(uspex_gui.optType,"1: MIN Enthalpy (stable phases)"); GUI_COMBOBOX_ADD(uspex_gui.optType,"2: MIN Volume (densest structure)"); GUI_COMBOBOX_ADD(uspex_gui.optType,"3: MAX Hardness (hardest phase)"); @@ -1693,18 +1670,19 @@ GUI_TOOLTIP(button,"Automatically determine bonds (recommended)."); GUI_COMBOBOX_ADD(uspex_gui.optType,"1110: MAX S-wave velocity"); GUI_COMBOBOX_ADD(uspex_gui.optType,"1111: MAX P-wave velocity"); GUI_TOOLTIP(uspex_gui.optType,"optType: Ch. 4.1 DEFAULT: 1(Enthalpy)\nSelect the properties to optimize."); - GUI_TEXT_TABLE(table,uspex_gui.new_optType,uspex_gui._tmp_new_optType,"NEW optType: ",2,5,5,6); + GUI_TEXT_TABLE(table,uspex_gui.new_optType,uspex_gui._tmp_new_optType,"NEW optType: ",1,3,7,8); GUI_TOOLTIP(uspex_gui.optType,"optType: Ch. 4.1 DEFAULT: MIN_enthalpy\nSelect the properties to optimize in the new\nVER 10.1 USPEX format."); - GUI_CHECK_TABLE(table,button,uspex_gui.have_new_opt,opt_toggle,"NEW",5,6,5,6); + GUI_CHECK_TABLE(table,button,uspex_gui.have_new_opt,opt_toggle,"NEW",3,4,7,8); GUI_TOOLTIP(button,"Use the VER 10.1 optType format.\nMandatory for multiobjective optimization."); -/* 7th line */ - /*col 0-2 is multiline*/ - GUI_CHECK_TABLE(table,button,uspex_gui.calc.anti_opt,NULL,"ANTI-OPT",2,3,6,7);/*not calling anything*/ +/* line 8 */ + /*col 1: empty*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.anti_opt,NULL,"ANTI-OPT",1,2,8,9);/*not calling anything*/ GUI_TOOLTIP(button,"anti-opt: - DEFAULT: FALSE\nIf set REVERSE the direction of optimization.\ni.e. MIN -> MAX & MAX -> MIN"); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMolecs",3,4,6,7);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMol",2,3,8,9);/*not calling anything*/ GUI_TOOLTIP(button,"checkMolecules: Ch. 4.1 DEFAULT: TRUE\nCheck and discard broken/merged molecules."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckConnect",4,5,6,7);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckCon",3,4,8,9);/*not calling anything*/ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardness and add connectivity in softmutation."); +/* <- Ext Pressure, LDA+U, and magRation moved to p. III, II, and III, respectively.*/ /* initialize */ GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); GUI_COMBOBOX_SETUP(uspex_gui.calculationType,0,uspex_type_selected); @@ -1719,173 +1697,204 @@ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardnes GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,goodBonds_selected); auto_bond_toggle(); opt_toggle(); +/* --- cell */ + GUI_LABEL_TABLE(table,"Cell",0,4,9,10); +/* line 10 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.Latticevalues,"Lattice:",0,1,10,11);/*multiline*/ +GUI_TOOLTIP(uspex_gui.Latticevalues,"Latticevalues: Ch. 4.6 DEFAULT: auto\nInitial volume of the unit cell, or known lattice parameters."); + GUI_TEXT_TABLE(table,uspex_gui._latticevalue,uspex_gui._tmp_latticevalue,"VALUES:",1,3,10,11); +GUI_TOOLTIP(uspex_gui._latticevalue,"VALUES: values of the current line of Latticevalues."); + GUI_APPLY_BUTTON_TABLE(table,button,apply_latticevalue,3,4,10,11); +/* line 11 */ + /*col 1: empty*/ + GUI_COMBOBOX_TABLE(table,uspex_gui._latticeformat,"FORMAT:",1,2,11,12); + GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Volumes"); + GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Lattice"); + GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Crystal"); +GUI_TOOLTIP(uspex_gui._latticeformat,"FORMAT: whether Lattice values correspond to a series of\nVolumes, lattive vectors, or crystallographic definition."); + GUI_TEXT_TABLE(table,uspex_gui.splitInto,uspex_gui._tmp_splitInto,"split:",2,3,11,12); +GUI_TOOLTIP(uspex_gui.splitInto,"splitInto: Ch. 4.5 DEFAULT: 1\nNumber of identical subcells or pseudosubcells in the unitcell."); + GUI_CHECK_TABLE(table,button,uspex_gui.auto_lval,toggle_auto_lval,"AUTO_LAT",3,4,11,12); +GUI_TOOLTIP(button,"AUTO_LAT: use automatic value for Latticevalues."); +/* Constraints */ + GUI_LABEL_TABLE(table,"Constraints",0,4,12,13); +/* line 13 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.IonDistances,"Ion:",0,1,13,14);/*multiline*/ +GUI_TOOLTIP(uspex_gui.IonDistances,"IonDistance: Ch. 4.5 DEFAULT: auto\nTriangular matrix of the minimum allowed\ninteratomic distances."); + GUI_TEXT_TABLE(table,uspex_gui._distances,uspex_gui._tmp_distances,"DIST: ",1,3,13,14); +GUI_TOOLTIP(uspex_gui._distances,"distances: minimum allowed distance from the current atom to others."); + GUI_APPLY_BUTTON_TABLE(table,button,apply_distances,3,4,13,14); +/* line 14 */ + /*col 1: empty*/ + GUI_ENTRY_TABLE(table,uspex_gui.minVectorLength,uspex_gui.calc.minVectorLength,"%.4f","MV:",1,2,14,15); +GUI_TOOLTIP(uspex_gui.minVectorLength,"minVectorLength: Ch. 4.5 DEFAULT: auto\nMinimum length of a new lattice parameter."); + GUI_ENTRY_TABLE(table,uspex_gui.constraint_enhancement,uspex_gui.calc.constraint_enhancement,"%i","CE:",2,3,14,15); +GUI_TOOLTIP(uspex_gui.constraint_enhancement,"constraint_enhancement: Ch. 4.5 DEFAULT: 1\nApply CE times the IonDistance constraints."); + GUI_CHECK_TABLE(table,button,uspex_gui.auto_C_ion,toggle_auto_C_ion,"AUTO_ION",3,4,14,15); +GUI_TOOLTIP(button,"AUTO_ION: use automatic values for ion constraints."); +/* line 15 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.MolCenters,"Mol:",0,1,15,16);/*multiline*/ +GUI_TOOLTIP(uspex_gui.MolCenters,"MolCenters: Ch. 4.5 DEFAULT: none\nTriangular matrix of the minimum allowed\ndistances between molecules centers."); + GUI_TEXT_TABLE(table,uspex_gui._centers,uspex_gui._tmp_centers,"CENTER:",1,3,15,16); +GUI_TOOLTIP(uspex_gui._centers,"centers: minimum allowed distance from the current molecule center to others."); + GUI_APPLY_BUTTON_TABLE(table,button,apply_centers,3,4,15,16); +/* line 16 */ + /*col 1: empty*/ + GUI_COMBOBOX_TABLE(table,uspex_gui._molModels,"Model:",1,3,16,17);/*NEW*/ + GUI_COMBOBOX_ADD(uspex_gui._molModels,"UNDER CONSTRUCTION"); +GUI_TOOLTIP(uspex_gui._centers,"Associate each molecule with a GDIS model."); + /*col 4: empty*/ +/* initialize */ + GUI_COMBOBOX_SETUP(uspex_gui.IonDistances,0,uspex_IonDistances_selected); + GUI_COMBOBOX_SETUP(uspex_gui.MolCenters,0,uspex_MolCenters_selected); + refresh_constraints(); + toggle_auto_C_ion(); + GUI_COMBOBOX_SETUP(uspex_gui._latticeformat,1,uspex_latticeformat_selected); + uspex_latticeformat_selected(uspex_gui._latticeformat); /* --- end frame */ -/* --- Population */ - GUI_FRAME_NOTE(page,frame,"Population"); -/* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,4,1); -/* 1st line */ - GUI_ENTRY_TABLE(table,uspex_gui.populationSize,uspex_gui.calc.populationSize,"%4i","SIZE:",0,1,0,1); + +/*---------------------*/ +/* page 2 -> STRUCTURE */ +/*---------------------*/ + GUI_PAGE_NOTE(notebook,page,"STRUCTURE"); +/* create a table in the page*/ + GUI_TABLE_NOTE(page,table,18,4); +/* --- Population & selection */ + GUI_LABEL_TABLE(table,"Population & selection",0,4,0,1); +/* line 1 */ + GUI_ENTRY_TABLE(table,uspex_gui.populationSize,uspex_gui.calc.populationSize,"%4i","SIZE:",0,1,1,2); GUI_TOOLTIP(uspex_gui.populationSize,"populationSize: Ch. 4.2 DEFAULT: auto\nNumber of structures in each generation."); - GUI_ENTRY_TABLE(table,uspex_gui.initialPopSize,uspex_gui.calc.initialPopSize,"%4i","INIT_SZ:",1,2,0,1); + GUI_ENTRY_TABLE(table,uspex_gui.initialPopSize,uspex_gui.calc.initialPopSize,"%4i","INIT:",1,2,1,2); GUI_TOOLTIP(uspex_gui.initialPopSize,"initialPopSize: Ch. 4.2 DEFAULT: populationSize\nNumber of structures in initial generation."); - GUI_ENTRY_TABLE(table,uspex_gui.numGenerations,uspex_gui.calc.numGenerations,"%4i","N_GENE:",2,3,0,1); + GUI_ENTRY_TABLE(table,uspex_gui.numGenerations,uspex_gui.calc.numGenerations,"%4i","NGEN:",2,3,1,2); GUI_TOOLTIP(uspex_gui.numGenerations,"numGenerations: Ch. 4.2 DEFAULT: 100\nMaximum number of generations."); - GUI_ENTRY_TABLE(table,uspex_gui.stopCrit,uspex_gui.calc.stopCrit,"%4i","STOP_CRIT:",3,4,0,1); + GUI_ENTRY_TABLE(table,uspex_gui.stopCrit,uspex_gui.calc.stopCrit,"%4i","STOP:",3,4,1,2); GUI_TOOLTIP(uspex_gui.stopCrit,"stopCrit: Ch. 4.2 DEFAULT: auto\nMaximum number of generations."); -/* --- end frame */ -/* --- Survival & Selection */ - GUI_FRAME_NOTE(page,frame,"Survival & Selection"); -/* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,4,1); -/* 1st line */ - GUI_ENTRY_TABLE(table,uspex_gui.bestFrac,uspex_gui.calc.bestFrac,"%.5f","BestFrac:",0,1,0,1); +/* line 2 */ + GUI_ENTRY_TABLE(table,uspex_gui.mag_nm,uspex_gui.calc.magRatio[0],"%.4f","N.M.:",0,1,2,3); +GUI_TOOLTIP(uspex_gui.mag_nm,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a non-magnetic order."); + GUI_ENTRY_TABLE(table,uspex_gui.mag_fmls,uspex_gui.calc.magRatio[1],"%.4f","FM-LS:",1,2,2,3); +GUI_TOOLTIP(uspex_gui.mag_fmls,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a low-spin ferromagnetic order."); + GUI_ENTRY_TABLE(table,uspex_gui.mag_afml,uspex_gui.calc.magRatio[3],"%.4f","AFM-L:",2,3,2,3); +GUI_TOOLTIP(uspex_gui.mag_afml,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a low-spin antiferromagnetic order."); + GUI_ENTRY_TABLE(table,uspex_gui.mag_fmlh,uspex_gui.calc.magRatio[5],"%.4f","FM-LH:",3,4,2,3); +GUI_TOOLTIP(uspex_gui.mag_fmlh,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a low/high spin mixed ferromagnetic order."); +/* line 3 */ + GUI_CHECK_TABLE(table,button,uspex_gui.calc._calctype_mag,mag_toggle,"MAG",0,1,3,4); +GUI_TOOLTIP(button,"Set a magnetic calculation."); + GUI_ENTRY_TABLE(table,uspex_gui.mag_fmhs,uspex_gui.calc.magRatio[2],"%.4f","FM-HS:",1,2,3,4); +GUI_TOOLTIP(uspex_gui.mag_fmhs,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a high-spin ferromagnetic."); + GUI_ENTRY_TABLE(table,uspex_gui.mag_afmh,uspex_gui.calc.magRatio[4],"%.4f","AFM-H:",2,3,3,4); +GUI_TOOLTIP(uspex_gui.mag_afmh,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a high-spin antiferromagnetic."); + GUI_ENTRY_TABLE(table,uspex_gui.mag_aflh,uspex_gui.calc.magRatio[6],"%.4f","AF-LH:",3,4,3,4); +GUI_TOOLTIP(uspex_gui.mag_aflh,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a low/high spin mixed antiferromagnetic."); +/* line 4 */ + GUI_ENTRY_TABLE(table,uspex_gui.bestFrac,uspex_gui.calc.bestFrac,"%.4f","Best:",0,1,4,5); GUI_TOOLTIP(uspex_gui.bestFrac,"bestFrac: Ch. 4.3 DEFAULT: 0.7\nFraction of current generation used to generate the next."); - GUI_ENTRY_TABLE(table,uspex_gui.keepBestHM,uspex_gui.calc.keepBestHM,"%3i","keepBestHM:",1,2,0,1); + GUI_ENTRY_TABLE(table,uspex_gui.keepBestHM,uspex_gui.calc.keepBestHM,"%3i","BestHM:",1,2,4,5); GUI_TOOLTIP(uspex_gui.keepBestHM,"keepBestHM: Ch. 4.3 DEFAULT: auto\nNumber of best structures that will survive in next generation."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.reoptOld,NULL,"reoptOld",2,3,0,1);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.reoptOld,NULL,"reopt",2,3,4,5);/*not calling anything*/ GUI_TOOLTIP(button,"reoptOld: Ch. 4.3 DEFAULT: FALSE\nIf set surviving structure will be re-optimized."); -/* --- end frame */ + GUI_ENTRY_TABLE(table,uspex_gui.fitLimit,uspex_gui.calc.fitLimit,"%.4f","BestFIT:",3,4,4,5); +GUI_TOOLTIP(uspex_gui.fitLimit,"fitLimit: Ch. 4.3 DEFAULT: none\nStop calculation when fitLimit fitness is reached."); /* --- Structure & Variation */ - GUI_FRAME_NOTE(page,frame,"Structure & Variation"); -/* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,5,3); -/* 1st line */ - GUI_TEXT_TABLE(table,uspex_gui.symmetries,uspex_gui.calc.symmetries,"symmetries: ",0,2,0,1); + GUI_LABEL_TABLE(table,"Structure & Variation",0,4,5,6); +/* line 6 */ + GUI_TEXT_TABLE(table,uspex_gui.symmetries,uspex_gui.calc.symmetries,"symmetries: ",0,4,6,7); GUI_TOOLTIP(uspex_gui.symmetries,"symmetries: Ch. 4.4 DEFAULT: auto\nPossible space group for crystals,\nplane group for 2D crystals/surface\nor point group for clusters."); - GUI_ENTRY_TABLE(table,uspex_gui.fracGene,uspex_gui.calc.fracGene,"%.4f","fracGene:",2,3,0,1); +/* line 7 */ + GUI_ENTRY_TABLE(table,uspex_gui.fracGene,uspex_gui.calc.fracGene,"%.4f","Heredity:",0,1,7,8); GUI_TOOLTIP(uspex_gui.fracGene,"fracGene: Ch. 4.4 DEFAULT: 0.5\nRatio of structures obtained by heredity."); - GUI_ENTRY_TABLE(table,uspex_gui.fracRand,uspex_gui.calc.fracRand,"%.4f","fracRand:",3,4,0,1); + GUI_ENTRY_TABLE(table,uspex_gui.fracRand,uspex_gui.calc.fracRand,"%.4f","Random:",1,2,7,8); GUI_TOOLTIP(uspex_gui.fracRand,"fracRand: Ch. 4.4 DEFAULT: 0.2\nRatio of structures obtained randomly."); - GUI_ENTRY_TABLE(table,uspex_gui.fracPerm,uspex_gui.calc.fracPerm,"%.4f","fracPerm:",4,5,0,1); + GUI_ENTRY_TABLE(table,uspex_gui.fracTopRand,uspex_gui.calc.fracTopRand,"%.4f","TOPRand:",2,3,7,8); +GUI_TOOLTIP(uspex_gui.fracTopRand,"fracTopRand: Ch. 4.4 DEFAULT: 0.2\nRatio of structures obtained by topological random generator."); + GUI_ENTRY_TABLE(table,uspex_gui.fracPerm,uspex_gui.calc.fracPerm,"%.4f","Permutation:",3,4,7,8); GUI_TOOLTIP(uspex_gui.fracPerm,"fracPerm: Ch. 4.4 DEFAULT: auto\nRatio of structures obtained by permutation."); -/* 2nd line */ - GUI_ENTRY_TABLE(table,uspex_gui.fracAtomsMut,uspex_gui.calc.fracAtomsMut,"%.4f","fracAtomsMut:",0,1,1,2); +/* line 8 */ + GUI_ENTRY_TABLE(table,uspex_gui.fracAtomsMut,uspex_gui.calc.fracAtomsMut,"%.4f","AtmMut:",0,1,8,9); GUI_TOOLTIP(uspex_gui.fracAtomsMut,"fracAtomsMut: Ch. 4.4 DEFAULT: 0.1\nRatio of structures obtained by softmutation."); - GUI_ENTRY_TABLE(table,uspex_gui.fracRotMut,uspex_gui.calc.fracRotMut,"%.4f","fracRotMut:",1,2,1,2); + GUI_ENTRY_TABLE(table,uspex_gui.fracRotMut,uspex_gui.calc.fracRotMut,"%.4f","RotMut:",1,2,8,9); GUI_TOOLTIP(uspex_gui.fracRotMut,"fracRotMut: Ch. 4.4 DEFAULT: auto\nRatio of structures obtained by mutation of molecular orientation."); - GUI_ENTRY_TABLE(table,uspex_gui.fracLatMut,uspex_gui.calc.fracLatMut,"%.4f","fracLatMut:",2,3,1,2); + GUI_ENTRY_TABLE(table,uspex_gui.fracLatMut,uspex_gui.calc.fracLatMut,"%.4f","LatMut:",2,3,8,9); GUI_TOOLTIP(uspex_gui.fracLatMut,"fracLatMut: Ch. 4.4 DEFAULT: auto\nRatio of structures obtained by lattice mutation."); - GUI_ENTRY_TABLE(table,uspex_gui.howManySwaps,uspex_gui.calc.howManySwaps,"%3i","N_SWAPS:",3,4,1,2); + GUI_ENTRY_TABLE(table,uspex_gui.fracSpinMut,uspex_gui.calc.fracSpinMut,"%.4f","SpinMut:",3,4,8,9); +GUI_TOOLTIP(uspex_gui.fracSpinMut,"fracSpinMut: Ch. 4.4 DEFAULT: 0.1\nRatio of structures obtained by spin mutation."); +/* line 9 */ + GUI_ENTRY_TABLE(table,uspex_gui.howManySwaps,uspex_gui.calc.howManySwaps,"%3i","NSwaps:",0,1,9,10); GUI_TOOLTIP(uspex_gui.howManySwaps,"howManySwaps: Ch. 4.4 DEFAULT: auto\nNumber of pairwise swaps for permutation\ndistributed uniformly between [1,howManySwaps]."); - GUI_TEXT_TABLE(table,uspex_gui.specificSwaps,uspex_gui.calc.specificSwaps,"SWAPS: ",4,5,1,2); + GUI_TEXT_TABLE(table,uspex_gui.specificSwaps,uspex_gui.calc.specificSwaps,"Swaps: ",1,4,9,10); GUI_TOOLTIP(uspex_gui.specificSwaps,"specificSwaps: Ch. 4.4 DEFAULT: blank\nWich atoms are allow to swap during permutation."); -/* 3rd line */ - GUI_ENTRY_TABLE(table,uspex_gui.mutationDegree,uspex_gui.calc.mutationDegree,"%.4f","mutationDegree:",0,1,2,3); +/* line 10 */ + GUI_ENTRY_TABLE(table,uspex_gui.mutationDegree,uspex_gui.calc.mutationDegree,"%.4f","mutationDegree:",0,1,10,11); GUI_TOOLTIP(uspex_gui.mutationDegree,"mutationDegree: Ch. 4.4 DEFAULT: auto\nMaximum displacement in softmutation (Ang)."); - GUI_ENTRY_TABLE(table,uspex_gui.mutationRate,uspex_gui.calc.mutationRate,"%.4f","mutationRate:",1,2,2,3); + GUI_ENTRY_TABLE(table,uspex_gui.mutationRate,uspex_gui.calc.mutationRate,"%.4f","mutationRate:",1,2,10,11); GUI_TOOLTIP(uspex_gui.mutationRate,"mutationRate: Ch. 4.4 DEFAULT: 0.5\nStd. dev. of epsilon in strain matrix for lattice mutation."); - GUI_ENTRY_TABLE(table,uspex_gui.DisplaceInLatmutation,uspex_gui.calc.DisplaceInLatmutation,"%.4f","D_LATMUT:",2,3,2,3); + GUI_ENTRY_TABLE(table,uspex_gui.DisplaceInLatmutation,uspex_gui.calc.DisplaceInLatmutation,"%.4f","D_LATMUT:",2,3,10,11); GUI_TOOLTIP(uspex_gui.DisplaceInLatmutation,"DisplaceInLatmutation: Ch. 4.4 DEFAULT: 1.0\nSets softmutation as part of lattice mutation\nand gives maximum displacement (Ang)."); - GUI_CHECK_TABLE(table,uspex_gui.AutoFrac,uspex_gui.calc.AutoFrac,NULL,"AutoFrac",3,4,2,3);/*not calling anything*/ + GUI_CHECK_TABLE(table,uspex_gui.AutoFrac,uspex_gui.calc.AutoFrac,NULL,"AutoFrac",3,4,10,11);/*not calling anything*/ GUI_TOOLTIP(uspex_gui.AutoFrac,"AutoFrac: Ch. 4.4 DEFAULT: FALSE\nIf set variation parameters will be optimized during run."); - GUI_CHECK_TABLE(table,button,uspex_gui.auto_SV,toggle_auto_SV,"AUTO_SV",4,5,2,3); -GUI_TOOLTIP(button,"AUTO_SV: use automatic values for all Structure and Variation Parameters."); +/* --- Fingerprint & Antiseeds */ + GUI_LABEL_TABLE(table,"Fingerprint, antiseed, & spacegroup",0,4,11,12); +/* line 12 */ + GUI_LABEL_TABLE(table,"Fingerprint",0,1,12,13); + GUI_ENTRY_TABLE(table,uspex_gui.RmaxFing,uspex_gui.calc.RmaxFing,"%.4f","RMax:",1,2,12,13); +GUI_TOOLTIP(uspex_gui.RmaxFing,"RmaxFing: Ch. 4.9 DEFAULT: 10.0\ncutoff distance (Ang.)."); + GUI_ENTRY_TABLE(table,uspex_gui.deltaFing,uspex_gui.calc.deltaFing,"%.4f","delta:",2,3,12,13); +GUI_TOOLTIP(uspex_gui.deltaFing,"deltaFing: Ch. 4.9 DEFAULT: 0.08\nDiscretization of the fingerprint function."); + GUI_ENTRY_TABLE(table,uspex_gui.sigmaFing,uspex_gui.calc.sigmaFing,"%.4f","sigma:",3,4,12,13); +GUI_TOOLTIP(uspex_gui.sigmaFing,"sigmaFing: Ch. 4.9 DEFAULT: 0.03\nGaussian broadening of interatomic distance."); +/* line 13 */ + GUI_LABEL_TABLE(table,"Antiseed",0,1,13,14); + GUI_ENTRY_TABLE(table,uspex_gui.antiSeedsActivation,uspex_gui.calc.antiSeedsActivation,"%4i","Activation:",1,2,13,14); +GUI_TOOLTIP(uspex_gui.antiSeedsActivation,"antiSeedsActivation: Ch. 4.10 DEFAULT: 5000\nGeneration at which antiseed is active."); + GUI_ENTRY_TABLE(table,uspex_gui.antiSeedsMax,uspex_gui.calc.antiSeedsMax,"%.4f","Max:",2,3,13,14); +GUI_TOOLTIP(uspex_gui.antiSeedsMax,"antiSeedsMax: Ch. 4.10 DEFAULT: 0.000\nGaussian height in mean square deviation of the generation enthalpy\nAmong bestFrac structures, recommended value is 0.01."); + GUI_ENTRY_TABLE(table,uspex_gui.antiSeedsSigma,uspex_gui.calc.antiSeedsSigma,"%.4f","sigma:",3,4,13,14); +GUI_TOOLTIP(uspex_gui.antiSeedsSigma,"antiSeedsSigma: Ch. 4.10 DEFAULT: 0.001\nGaussian width in average distances between generated structure\nAmong bestFrac structures, recommended calue is 0.005."); +/* line 14 */ + GUI_LABEL_TABLE(table,"Space group",0,1,14,15); + /*col 2: empty*/ + GUI_CHECK_TABLE(table,uspex_gui.doSpaceGroup,uspex_gui.calc.doSpaceGroup,SG_toggle,"Active",2,3,14,15); +GUI_TOOLTIP(uspex_gui.doSpaceGroup,"doSpaceGroup: Ch. 4.11 DEFAULT: TRUE\nActivate space group determination."); + GUI_ENTRY_TABLE(table,uspex_gui.SymTolerance,uspex_gui.calc.SymTolerance,"%.4f","TOL:",3,4,14,15); +GUI_TOOLTIP(uspex_gui.SymTolerance,"SymTolerance: Ch. 4.11 DEFAULT: 0.10\nPrecision for symmetry determination."); /* initialize */ - toggle_auto_SV(); -/* --- end frame */ -/* --- Constraints */ - GUI_FRAME_NOTE(page,frame,"Constraints"); -/* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,6,2); -/* 1st line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.IonDistances,"IonDistance:",0,1,0,1); -GUI_TOOLTIP(uspex_gui.IonDistances,"IonDistance: Ch. 4.5 DEFAULT: auto\nTriangular matrix of the minimum allowed\ninteratomic distances."); - GUI_ENTRY_TABLE(table,uspex_gui.curr_distance,uspex_gui._curr_distance,"%3i","CURRENT:",1,2,0,1); -GUI_TOOLTIP(uspex_gui.curr_distance,"Current atom"); -GUI_LOCK(uspex_gui.curr_distance); - GUI_TEXT_TABLE(table,uspex_gui._distances,uspex_gui._tmp_distances,"DIST: ",2,3,0,1); -GUI_TOOLTIP(uspex_gui._distances,"distances: minimum allowed distance from the current atom to others."); - GUI_APPLY_BUTTON_TABLE(table,button,apply_distances,3,4,0,1); - GUI_ENTRY_TABLE(table,uspex_gui.minVectorLength,uspex_gui.calc.minVectorLength,"%.4f","MIN_VECT:",4,5,0,1); -GUI_TOOLTIP(uspex_gui.minVectorLength,"minVectorLength: Ch. 4.5 DEFAULT: auto\nMinimum length of a new lattice parameter."); - GUI_CHECK_TABLE(table,button,uspex_gui.auto_C_ion,toggle_auto_C_ion,"AUTO_ION",5,6,0,1); -GUI_TOOLTIP(button,"AUTO_ION: use automatic values for ion constraints."); -/* 2nd line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.MolCenters,"MolCenters:",0,1,1,2); -GUI_TOOLTIP(uspex_gui.MolCenters,"MolCenters: Ch. 4.5 DEFAULT: none\nTriangular matrix of the minimum allowed\ndistances between molecules centers."); - GUI_ENTRY_TABLE(table,uspex_gui.curr_center,uspex_gui._curr_center,"%3i","CURRENT:",1,2,1,2); -GUI_TOOLTIP(uspex_gui.curr_center,"Current molecule"); -GUI_LOCK(uspex_gui.curr_center); - GUI_TEXT_TABLE(table,uspex_gui._centers,uspex_gui._tmp_centers,"CENTER:",2,3,1,2); -GUI_TOOLTIP(uspex_gui._centers,"centers: minimum allowed distance from the current molecule center to others."); - GUI_APPLY_BUTTON_TABLE(table,button,apply_centers,3,4,1,2); - GUI_ENTRY_TABLE(table,uspex_gui.constraint_enhancement,uspex_gui.calc.constraint_enhancement,"%i","CE:",4,5,1,2); -GUI_TOOLTIP(uspex_gui.constraint_enhancement,"constraint_enhancement: Ch. 4.5 DEFAULT: 1\nApply CE times the IonDistance constraints."); - GUI_CHECK_TABLE(table,button,uspex_gui.auto_C_lat,toggle_auto_C_lat,"AUTO_LAT",5,6,1,2); -GUI_TOOLTIP(button,"AUTO_LAT: use automatic value for minVectorLength."); -/* initialize */ - GUI_COMBOBOX_SETUP(uspex_gui.IonDistances,0,uspex_IonDistances_selected); - GUI_COMBOBOX_SETUP(uspex_gui.MolCenters,0,uspex_MolCenters_selected); - refresh_constraints(); - toggle_auto_C_ion(); - toggle_auto_C_lat(); -/* --- end frame */ -/* --- Cell */ - GUI_FRAME_NOTE(page,frame,"Cell"); -/* create a table in the frame*/ - GUI_TABLE_FRAME(frame,table,5,1); -/* 1st line */ - GUI_COMBOBOX_TABLE(table,uspex_gui.Latticevalues,"Latticevalues:",0,1,0,1); -GUI_TOOLTIP(uspex_gui.Latticevalues,"Latticevalues: Ch. 4.6 DEFAULT: auto\nInitial volume of the unit cell, or known lattice parameters."); - GUI_COMBOBOX_TABLE(table,uspex_gui._latticeformat,"FORMAT:",1,2,0,1); - GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Volumes"); - GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Lattice"); - GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Crystal"); -GUI_TOOLTIP(uspex_gui._latticeformat,"FORMAT: whether Lattice values correspond to a series of\nVolumes, lattive vectors, or crystallographic definition."); - GUI_TEXT_TABLE(table,uspex_gui._latticevalue,uspex_gui._tmp_latticevalue,"VALUES: ",2,3,0,1); -GUI_TOOLTIP(uspex_gui._latticevalue,"VALUES: values of the current line of Latticevalues."); - GUI_APPLY_BUTTON_TABLE(table,button,apply_latticevalue,3,4,0,1); - GUI_TEXT_TABLE(table,uspex_gui.splitInto,uspex_gui._tmp_splitInto,"splitInto:",4,5,0,1); -GUI_TOOLTIP(uspex_gui.splitInto,"splitInto: Ch. 4.5 DEFAULT: 1\nNumber of identical subcells or pseudosubcells in the unitcell."); - GUI_CHECK_TABLE(table,button,uspex_gui.auto_lval,toggle_auto_lval,"AUTO_LVAL",5,6,0,1); -GUI_TOOLTIP(button,"AUTO_LVAL: use automatic value for Latticevalues."); -/* initialize */ - GUI_COMBOBOX_SETUP(uspex_gui._latticeformat,0,uspex_latticeformat_selected); -/* --- end frame */ - - - - - + SG_toggle(); +/* --- Variable-composition */ + GUI_LABEL_TABLE(table,"Variable-composition",0,4,15,16); +/* line 16 */ + GUI_ENTRY_TABLE(table,uspex_gui.firstGeneMax,uspex_gui.calc.firstGeneMax,"%4i","1st_Gen:",0,1,16,17); +GUI_TOOLTIP(uspex_gui.firstGeneMax,"firstGeneMax: Ch. 5.5 DEFAULT: 11\nNumber of composition sampled in 1st generation."); + GUI_ENTRY_TABLE(table,uspex_gui.minAt,uspex_gui.calc.minAt,"%4i","min@:",1,2,16,17); +GUI_TOOLTIP(uspex_gui.minAt,"minAt: Ch. 5.5 DEFAULT: none\nMinimum number of atoms (molecules) in unitcell\nfor the first generation."); + GUI_ENTRY_TABLE(table,uspex_gui.maxAt,uspex_gui.calc.maxAt,"%4i","max@:",2,3,16,17); +GUI_TOOLTIP(uspex_gui.maxAt,"maxAt: Ch. 5.5 DEFAULT: none\nMaximum number of atoms (molecules) in unitcell\nfor the first generation."); +/*col 4: empty*/ +/* line 17 */ + GUI_ENTRY_TABLE(table,uspex_gui.fracTrans,uspex_gui.calc.fracTrans,"%.4f","Trans:",0,1,17,18); +GUI_TOOLTIP(uspex_gui.fracTrans,"fracTrans: Ch. 5.5 DEFAULT: 0.1\nratio of structures obtained by transmutation."); + GUI_ENTRY_TABLE(table,uspex_gui.howManyTrans,uspex_gui.calc.howManyTrans,"%.4f","NTrans:",1,2,17,18); +GUI_TOOLTIP(uspex_gui.howManyTrans,"howManyTrans: Ch. 5.5 DEFAULT: 0.2\nMaximum ratio of transmutated atoms in a structure."); + GUI_ENTRY_TABLE(table,uspex_gui.specificTrans,uspex_gui._tmp_specificTrans,"%s","Specific:",2,4,17,18); +GUI_TOOLTIP(uspex_gui.specificTrans,"specificTrans: Ch. 5.5 DEFAULT: blank\nList of allowed transmutation."); - - - - - - - - - - - - - - - -/*------------------*/ -/* page 2 -> SET-II */ -/*------------------*/ - GUI_PAGE_NOTE(notebook,page,"SET-II"); -/* --- end frame */ - -/*---------------------*/ -/* page 3 -> SPECIFICS */ -/*---------------------*/ - GUI_PAGE_NOTE(notebook,page,"SPECIFICS"); +/*-----------------------*/ +/* page 3 -> CALCULATION */ +/*-----------------------*/ + GUI_PAGE_NOTE(notebook,page,"CALCULATION"); /* --- end frame */ /*--------------------*/ -/* page 4 -> ABINITIO */ +/* page 4 -> ADVANCED */ /*--------------------*/ - GUI_PAGE_NOTE(notebook,page,"AB INITIO"); + GUI_PAGE_NOTE(notebook,page,"ADVANCED"); /* --- end frame */ -/*----------------*/ -/* page 5 -> EXEC */ -/*----------------*/ - GUI_PAGE_NOTE(notebook,page,"EXEC"); +/*--------------------*/ +/* page 5 -> SPECIFIC */ +/*--------------------*/ + GUI_PAGE_NOTE(notebook,page,"SPECIFIC"); /* --- end frame */ /* --- Outside of notebook */ diff --git a/src/gui_uspex.h b/src/gui_uspex.h index 9b47f4b..380bcf4 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -79,11 +79,19 @@ struct uspex_calc_gui{ /**/ //checkMolecules is auto-sync //checkConnectivity is auto-sync + GUI_OBJ *fitLimit; /*VER 10.1*/ /*4.2 Population*/ GUI_OBJ *populationSize; GUI_OBJ *initialPopSize; GUI_OBJ *numGenerations; GUI_OBJ *stopCrit; + GUI_OBJ *mag_nm; /*VER 10.1*/ + GUI_OBJ *mag_fmls; /*VER 10.1*/ + GUI_OBJ *mag_fmhs; /*VER 10.1*/ + GUI_OBJ *mag_afml; /*VER 10.1*/ + GUI_OBJ *mag_afmh; /*VER 10.1*/ + GUI_OBJ *mag_fmlh; /*VER 10.1*/ + GUI_OBJ *mag_aflh; /*VER 10.1*/ /*4.3 Survival of the fittest & Selection*/ GUI_OBJ *bestFrac; GUI_OBJ *keepBestHM; @@ -92,32 +100,34 @@ struct uspex_calc_gui{ GUI_OBJ *symmetries; GUI_OBJ *fracGene; GUI_OBJ *fracRand; + GUI_OBJ *fracTopRand; /*VER 10.1*/ GUI_OBJ *fracPerm; GUI_OBJ *fracAtomsMut; GUI_OBJ *fracRotMut; GUI_OBJ *fracLatMut; + GUI_OBJ *fracSpinMut; /*VER 10.1*/ GUI_OBJ *howManySwaps; GUI_OBJ *specificSwaps; GUI_OBJ *mutationDegree; GUI_OBJ *mutationRate; GUI_OBJ *DisplaceInLatmutation; GUI_OBJ *AutoFrac; - gboolean auto_SV; /*4.5 Constrains*/ GUI_OBJ *IonDistances; GUI_OBJ *_distances; gchar *_tmp_distances; - GUI_OBJ *curr_distance; +// GUI_OBJ *curr_distance; gint _curr_distance; GUI_OBJ *minVectorLength; GUI_OBJ *MolCenters; GUI_OBJ *_centers; gchar *_tmp_centers; - GUI_OBJ *curr_center; +// GUI_OBJ *curr_center; gint _curr_center; GUI_OBJ *constraint_enhancement; gboolean auto_C_ion; gboolean auto_C_lat; + GUI_OBJ *_molModels; /*4.6 Cell*/ GUI_OBJ *Latticevalues; GUI_OBJ *_latticeformat; @@ -126,8 +136,28 @@ struct uspex_calc_gui{ GUI_OBJ *splitInto; gchar *_tmp_splitInto; gboolean auto_lval; +/*4.9 fingerprint*/ + GUI_OBJ *RmaxFing; + GUI_OBJ *deltaFing; + GUI_OBJ *sigmaFing; +/*4.10 Antiseed*/ + GUI_OBJ *antiSeedsActivation; + GUI_OBJ *antiSeedsMax; + GUI_OBJ *antiSeedsSigma; +/*4.11 spacegroup*/ + GUI_OBJ *doSpaceGroup; + GUI_OBJ *SymTolerance; +/*5.5 variable composition*/ + GUI_OBJ *firstGeneMax; + GUI_OBJ *minAt; + GUI_OBJ *maxAt; + GUI_OBJ *fracTrans; + GUI_OBJ *howManyTrans; + gchar *_tmp_specificTrans; + GUI_OBJ *specificTrans; + /* CALCUL */ GUI_OBJ *job_uspex_exe; GUI_OBJ *job_path; From e1f9ec96cacb61b82c59c0fa9135501b34d199b8 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 8 Nov 2018 18:48:24 +0900 Subject: [PATCH 39/56] gui_uspex: uspex parameters III VER 10.1 --- src/file_uspex.c | 1 + src/gui_uspex.c | 439 ++++++++++++++++++++++++++++++++++++++++++++--- src/gui_uspex.h | 88 +++++++++- 3 files changed, 498 insertions(+), 30 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 08b7960..45a96e2 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -1498,6 +1498,7 @@ void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ else if(_SRC._nlatticevalues==1) _DBLCP(Latticevalues,1); } _COPY(splitInto,_SRC._nsplits,gint); + _CP(_num_opt_steps); _COPY(abinitioCode,_SRC._num_opt_steps,gint); _DBLCP(KresolStart,_SRC._num_opt_steps); _DBLCP(vacuumSize,_SRC._num_opt_steps); diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 2eeb5df..043fee8 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -63,7 +63,7 @@ struct uspex_calc_gui uspex_gui; void gui_uspex_init(struct model_pak *model){ gint idx; gchar *line; - uspex_gui.cur_page=USPEX_PAGE_SET_I; + uspex_gui.cur_page=USPEX_PAGE_SYSTEM; /*prepare local values*/ uspex_gui._tmp_atom_typ=0;uspex_gui._tmp_atom_num=0;uspex_gui._tmp_atom_val=0; strcpy(uspex_gui._tmp_atom_sym,elements[uspex_gui._tmp_atom_typ].symbol); @@ -75,6 +75,9 @@ void gui_uspex_init(struct model_pak *model){ uspex_gui._tmp_specificTrans=line; line=NULL; } + + uspex_gui._tmp_num_opt_steps=(gdouble)uspex_gui.calc._num_opt_steps; + uspex_gui._tmp_curr_step=1.; /*get atom information if not available*/ if(uspex_gui.calc.atomType==NULL){ GSList *list; @@ -543,7 +546,7 @@ void _update_calculationType(){ /************************/ /* update _calctype_dim */ /************************/ -void spin_update_dim(){ +void spin_update_dim(void){ gint i=(gint)uspex_gui._dim; /*ban the -1 value*/ if(i==-1){ @@ -632,6 +635,27 @@ void mag_toggle(void){ uspex_gui.calc.calculationType*=sgn; /*done, now update calculationType*/ _update_calculationType(); + /*now enable/disable mag-related items*/ + if(uspex_gui.calc._calctype_mag){ + GUI_UNLOCK(uspex_gui.mag_nm); + GUI_UNLOCK(uspex_gui.mag_fmls); + GUI_UNLOCK(uspex_gui.mag_fmhs); + GUI_UNLOCK(uspex_gui.mag_afml); + GUI_UNLOCK(uspex_gui.mag_afmh); + GUI_UNLOCK(uspex_gui.mag_fmlh); + GUI_UNLOCK(uspex_gui.mag_aflh); + GUI_UNLOCK(uspex_gui.fracSpinMut); + + }else{ + GUI_LOCK(uspex_gui.mag_nm); + GUI_LOCK(uspex_gui.mag_fmls); + GUI_LOCK(uspex_gui.mag_fmhs); + GUI_LOCK(uspex_gui.mag_afml); + GUI_LOCK(uspex_gui.mag_afmh); + GUI_LOCK(uspex_gui.mag_fmlh); + GUI_LOCK(uspex_gui.mag_aflh); + GUI_LOCK(uspex_gui.fracSpinMut); + } } /***********************************/ /* selecting optimization property */ @@ -1327,6 +1351,153 @@ void SG_toggle(void){ GUI_LOCK(uspex_gui.SymTolerance); } } +/*************************************************/ +/* change the total number of optimisation steps */ +/*************************************************/ +void spin_update_num_opt_steps(void){ + + + + /*update current step range*/ + GUI_SPIN_RANGE(uspex_gui._curr_step,1.,uspex_gui._tmp_num_opt_steps); +} +/***************************/ +/* change the current step */ +/***************************/ +void spin_update_curr_step(void){ + +} +/********************************/ +/* toggle full/fixed relaxation */ +/********************************/ +void toggle_isfull(void){ + +} +/***************************************/ +/* define an ab initio code executable */ +/***************************************/ +void load_abinito_exe_dialog(void){ + +} +/************************************/ +/* set the uspex calculation folder */ +/************************************/ +void load_job_path(void){ + +} +/******************************************************************/ +/* sets a remote folder (in case it can be set by a local folder) */ +/******************************************************************/ +void load_remote_folder(void){ + +} + +/**************************/ +/* select dynamicalBestHM */ +/**************************/ +void uspex_dyn_HM_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 0: + uspex_gui.calc.dynamicalBestHM=0; + break; + case 1: + uspex_gui.calc.dynamicalBestHM=1; + break; + case 2: + /* fall through */ + default: + uspex_gui.calc.dynamicalBestHM=2; + } +} +/**********************/ +/* select manyParents */ +/**********************/ +void uspex_manyParents_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + uspex_gui.calc.manyParents=1; + break; + case 2: + uspex_gui.calc.manyParents=2; + break; + case 3: + uspex_gui.calc.manyParents=3; + break; + case 0: + /* fall through */ + default: + uspex_gui.calc.manyParents=0; + } +} +/******************/ +/* select TE_goal */ +/******************/ +void uspex_TE_goal_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + uspex_gui.calc.TE_goal=US_BT_ZTxx; + break; + case 2: + uspex_gui.calc.TE_goal=US_BT_ZTyy; + break; + case 3: + uspex_gui.calc.TE_goal=US_BT_ZTzz; + break; + case 0: + /* fall through */ + default: + uspex_gui.calc.TE_goal=US_BT_ZT; + } +} +/*************************************/ +/* load the BoltzTraP script/command */ +/*************************************/ +void load_cmd_BoltzTraP(void){ + +} +/*******************************/ +/* load orderParameter command */ +/*******************************/ +void load_cmd_OP(void){ + +} +/************************************/ +/* load enthalpyTemperature command */ +/************************************/ +void load_cmd_ET(void){ + +} +/***************************/ +/*load orderParameter file */ +/***************************/ +void load_OP_file(void){ + +} +/********************************/ +/*load enthalpyTemperature file */ +/********************************/ +void load_ET_file(){ + +} +/************************/ +/* load trajectory file */ +/************************/ +void load_traj_file(){ + +} +/************************/ +/* load MD restart file */ +/************************/ +void load_MDrestart_file(){ + +} + /************************/ /* Switch notebook page */ @@ -1339,15 +1510,25 @@ void uspex_gui_page_switch(GUI_NOTE *notebook,GUI_OBJ *page,guint page_num){ if(from_page==(gint)page_num) return;/*not moved*/ uspex_gui.cur_page=page_num; GUI_LOCK(page); - if(page_num==USPEX_PAGE_SET_I){ - /**/ - } else if(page_num==USPEX_PAGE_SET_II){ - /**/ - } else if (page_num==USPEX_PAGE_SPECIFICS){ + if(page_num==USPEX_PAGE_SYSTEM){ + /*sync uspex_gui._calctype_mag*/ + if(uspex_gui.calc._calctype_mag) { + GUI_TOGGLE_ON(uspex_gui._calctype_mag); + }else{ + GUI_TOGGLE_OFF(uspex_gui._calctype_mag); + } + } else if(page_num==USPEX_PAGE_STRUCTURES){ + /*sync uspex_gui._calctype_mag_2*/ + if(uspex_gui.calc._calctype_mag) { + GUI_TOGGLE_ON(uspex_gui._calctype_mag_2); + }else{ + GUI_TOGGLE_OFF(uspex_gui._calctype_mag_2); + } + } else if (page_num==USPEX_PAGE_CALCULATION){ /**/ - } else if (page_num==USPEX_PAGE_ABINITIO){ + } else if (page_num==USPEX_PAGE_ADVANCED){ /**/ - } else if (page_num==USPEX_PAGE_EXEC){ + } else if (page_num==USPEX_PAGE_SPECIFIC){ /**/ } GUI_UNLOCK(page); @@ -1500,7 +1681,7 @@ void gui_uspex_dialog(void){ /* special */ struct model_pak *data; // struct core_pak *core; -// gint idx; + gint idx; gchar *tmp; /* checks */ data = sysenv.active_model; @@ -1574,7 +1755,7 @@ GUI_TOOLTIP(uspex_gui.file_entry,"Use the previous result of a USPEX calculation /*------------------*/ GUI_PAGE_NOTE(notebook,page,"SYSTEM"); /* create a table in the page*/ - GUI_TABLE_NOTE(page,table,17,4); + GUI_TABLE_NOTE(page,table,18,4); /* --- Type & System */ GUI_LABEL_TABLE(table,"Type & System",0,4,0,1); /* line 1 */ @@ -1693,7 +1874,6 @@ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardnes GUI_SPIN_SET(uspex_gui._calctype_dim,(gdouble) uspex_gui.calc._calctype_dim); mol_toggle(); var_toggle(); - mag_toggle(); GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,goodBonds_selected); auto_bond_toggle(); opt_toggle(); @@ -1744,6 +1924,8 @@ GUI_TOOLTIP(uspex_gui._centers,"centers: minimum allowed distance from the curre GUI_COMBOBOX_ADD(uspex_gui._molModels,"UNDER CONSTRUCTION"); GUI_TOOLTIP(uspex_gui._centers,"Associate each molecule with a GDIS model."); /*col 4: empty*/ +/* line 17: empty */ + GUI_LABEL_TABLE(table," ",0,4,17,18); /* initialize */ GUI_COMBOBOX_SETUP(uspex_gui.IonDistances,0,uspex_IonDistances_selected); GUI_COMBOBOX_SETUP(uspex_gui.MolCenters,0,uspex_MolCenters_selected); @@ -1751,7 +1933,7 @@ GUI_TOOLTIP(uspex_gui._centers,"Associate each molecule with a GDIS model."); toggle_auto_C_ion(); GUI_COMBOBOX_SETUP(uspex_gui._latticeformat,1,uspex_latticeformat_selected); uspex_latticeformat_selected(uspex_gui._latticeformat); -/* --- end frame */ +/* --- end page */ /*---------------------*/ /* page 2 -> STRUCTURE */ @@ -1780,8 +1962,8 @@ GUI_TOOLTIP(uspex_gui.mag_afml,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calcul GUI_ENTRY_TABLE(table,uspex_gui.mag_fmlh,uspex_gui.calc.magRatio[5],"%.4f","FM-LH:",3,4,2,3); GUI_TOOLTIP(uspex_gui.mag_fmlh,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a low/high spin mixed ferromagnetic order."); /* line 3 */ - GUI_CHECK_TABLE(table,button,uspex_gui.calc._calctype_mag,mag_toggle,"MAG",0,1,3,4); -GUI_TOOLTIP(button,"Set a magnetic calculation."); + GUI_CHECK_TABLE(table,uspex_gui._calctype_mag_2,uspex_gui.calc._calctype_mag,mag_toggle,"MAG",0,1,3,4); +GUI_TOOLTIP(uspex_gui._calctype_mag_2,"Set a magnetic calculation."); GUI_ENTRY_TABLE(table,uspex_gui.mag_fmhs,uspex_gui.calc.magRatio[2],"%.4f","FM-HS:",1,2,3,4); GUI_TOOLTIP(uspex_gui.mag_fmhs,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calculation) Initial ratio of structures\nwith a high-spin ferromagnetic."); GUI_ENTRY_TABLE(table,uspex_gui.mag_afmh,uspex_gui.calc.magRatio[4],"%.4f","AFM-H:",2,3,3,4); @@ -1827,11 +2009,11 @@ GUI_TOOLTIP(uspex_gui.howManySwaps,"howManySwaps: Ch. 4.4 DEFAULT: auto\nNumber GUI_TOOLTIP(uspex_gui.specificSwaps,"specificSwaps: Ch. 4.4 DEFAULT: blank\nWich atoms are allow to swap during permutation."); /* line 10 */ GUI_ENTRY_TABLE(table,uspex_gui.mutationDegree,uspex_gui.calc.mutationDegree,"%.4f","mutationDegree:",0,1,10,11); -GUI_TOOLTIP(uspex_gui.mutationDegree,"mutationDegree: Ch. 4.4 DEFAULT: auto\nMaximum displacement in softmutation (Ang)."); +GUI_TOOLTIP(uspex_gui.mutationDegree,"mutationDegree: Ch. 4.13 DEFAULT: auto\nMaximum displacement in softmutation (Ang)."); GUI_ENTRY_TABLE(table,uspex_gui.mutationRate,uspex_gui.calc.mutationRate,"%.4f","mutationRate:",1,2,10,11); -GUI_TOOLTIP(uspex_gui.mutationRate,"mutationRate: Ch. 4.4 DEFAULT: 0.5\nStd. dev. of epsilon in strain matrix for lattice mutation."); +GUI_TOOLTIP(uspex_gui.mutationRate,"mutationRate: Ch. 4.13 DEFAULT: 0.5\nStd. dev. of epsilon in strain matrix for lattice mutation."); GUI_ENTRY_TABLE(table,uspex_gui.DisplaceInLatmutation,uspex_gui.calc.DisplaceInLatmutation,"%.4f","D_LATMUT:",2,3,10,11); -GUI_TOOLTIP(uspex_gui.DisplaceInLatmutation,"DisplaceInLatmutation: Ch. 4.4 DEFAULT: 1.0\nSets softmutation as part of lattice mutation\nand gives maximum displacement (Ang)."); +GUI_TOOLTIP(uspex_gui.DisplaceInLatmutation,"DisplaceInLatmutation: Ch. ?.? DEFAULT: 1.0\nSets softmutation as part of lattice mutation\nand gives maximum displacement (Ang).\nThis keyword has disapear in the 10.1 version of USPEX."); GUI_CHECK_TABLE(table,uspex_gui.AutoFrac,uspex_gui.calc.AutoFrac,NULL,"AutoFrac",3,4,10,11);/*not calling anything*/ GUI_TOOLTIP(uspex_gui.AutoFrac,"AutoFrac: Ch. 4.4 DEFAULT: FALSE\nIf set variation parameters will be optimized during run."); /* --- Fingerprint & Antiseeds */ @@ -1872,30 +2054,237 @@ GUI_TOOLTIP(uspex_gui.minAt,"minAt: Ch. 5.5 DEFAULT: none\nMinimum number of ato GUI_TOOLTIP(uspex_gui.maxAt,"maxAt: Ch. 5.5 DEFAULT: none\nMaximum number of atoms (molecules) in unitcell\nfor the first generation."); /*col 4: empty*/ /* line 17 */ - GUI_ENTRY_TABLE(table,uspex_gui.fracTrans,uspex_gui.calc.fracTrans,"%.4f","Trans:",0,1,17,18); -GUI_TOOLTIP(uspex_gui.fracTrans,"fracTrans: Ch. 5.5 DEFAULT: 0.1\nratio of structures obtained by transmutation."); - GUI_ENTRY_TABLE(table,uspex_gui.howManyTrans,uspex_gui.calc.howManyTrans,"%.4f","NTrans:",1,2,17,18); + GUI_ENTRY_TABLE(table,uspex_gui.fracTrans,uspex_gui.calc.fracTrans,"%.4f","fTrans:",0,1,17,18); +GUI_TOOLTIP(uspex_gui.fracTrans,"fracTrans: Ch. 5.5 DEFAULT: 0.1\nFraction of structures obtained by transmutation."); + GUI_ENTRY_TABLE(table,uspex_gui.howManyTrans,uspex_gui.calc.howManyTrans,"%.4f","rTrans:",1,2,17,18); GUI_TOOLTIP(uspex_gui.howManyTrans,"howManyTrans: Ch. 5.5 DEFAULT: 0.2\nMaximum ratio of transmutated atoms in a structure."); - GUI_ENTRY_TABLE(table,uspex_gui.specificTrans,uspex_gui._tmp_specificTrans,"%s","Specific:",2,4,17,18); + GUI_TEXT_TABLE(table,uspex_gui.specificTrans,uspex_gui._tmp_specificTrans,"Trans: ",2,4,17,18); GUI_TOOLTIP(uspex_gui.specificTrans,"specificTrans: Ch. 5.5 DEFAULT: blank\nList of allowed transmutation."); +/* initialize */ + mag_toggle(); + /*-----------------------*/ /* page 3 -> CALCULATION */ /*-----------------------*/ GUI_PAGE_NOTE(notebook,page,"CALCULATION"); -/* --- end frame */ +/* create a table in the page*/ + GUI_TABLE_NOTE(page,table,18,4); +/* --- Ab initio */ + GUI_LABEL_TABLE(table,"Ab initio",0,4,0,1); +/* line 1 */ + GUI_SPIN_TABLE(table,uspex_gui._num_opt_steps,uspex_gui._tmp_num_opt_steps,spin_update_num_opt_steps,"N_STEPS",0,1,1,2); + GUI_SPIN_RANGE(uspex_gui._num_opt_steps,1.,(gdouble)USPEX_MAX_NUM_OPT_STEPS); +GUI_TOOLTIP(uspex_gui._num_opt_steps,"Set the number of optimisation steps.\nIncluding fixed-cells and full relaxation steps."); + GUI_ENTRY_TABLE(table,uspex_gui.numParallelCalcs,uspex_gui.calc.numParallelCalcs,"%i","PAR:",1,2,1,2); +GUI_TOOLTIP(uspex_gui.numParallelCalcs,"numParallelCalcs: Ch. 4.8 DEFAULT: 1\nNumber of structure relaxations in parallel."); + GUI_ENTRY_TABLE(table,uspex_gui.whichCluster,uspex_gui.calc.whichCluster,"%i","Cluster:",2,3,1,2); +GUI_TOOLTIP(uspex_gui.whichCluster,"whichCluster: Ch. 4.8 DEFAULT: 0\nType of job submission, including:\n0 - no job-script;\n1 - local submission;\n2 - remote submission."); + GUI_CHECK_TABLE(table,button,uspex_gui.calc.PhaseDiagram,NULL,"PhaseDiag",3,4,1,2);/*not calling anything*/ +GUI_TOOLTIP(button,"PhaseDiagram: Ch. 4.8 DEFAULT: FALSE\nSet calculation of an estimated phase diagram\nfor calculationMethod 30X (300, 301, s300, and s301)."); +/* line 2 */ + GUI_SPIN_TABLE(table,uspex_gui._curr_step,uspex_gui._tmp_curr_step,spin_update_curr_step,"STEPS #",0,1,2,3); + GUI_SPIN_RANGE(uspex_gui._curr_step,1.,uspex_gui._tmp_num_opt_steps); +GUI_TOOLTIP(uspex_gui._curr_step,"Select current optimisation step number."); + GUI_CHECK_TABLE(table,button,uspex_gui._tmp_isfull,toggle_isfull,"Relax_full",1,2,2,3); +GUI_TOOLTIP(button,"Set the current step as a full relaxation.\nThis implies a mix between fixed and full relaxations."); + GUI_COMBOBOX_TABLE(table,uspex_gui.abinitioCode,"CODE:",2,4,2,3); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"1 - VASP"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"2 - SIESTA"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"3 - GULP"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"4 - LAMMPS"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"5 - ORCA"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"6 - DMACRYS"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"7 - CP2K"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"8 - QE"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"9 - FHI-aims"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"10 - ATK"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"11 - CASTEP"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"12 - Tinker"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"13 - MOPAC"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"14 - BoltzTraP"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"15 - DFTB"); + GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"16 - Gaussian"); +GUI_TOOLTIP(uspex_gui.abinitioCode,"abinitioCode: Ch. 4.8 DEFAULT: 1\nCode used for the calculations in this step."); +/* line 3 */ + GUI_ENTRY_TABLE(table,uspex_gui.KresolStart,uspex_gui._tmp_KresolStart,"%.4f","Kresol:",0,1,3,4); +GUI_TOOLTIP(uspex_gui.KresolStart,"KresolStart: Ch. 4.8 DEFAULT: 0.2-0.08\nReciprocal-space resolution for this optimization step (2*pi/Ang)."); + GUI_ENTRY_TABLE(table,uspex_gui.vacuumSize,uspex_gui._tmp_vacuumSize,"%.4f","vacuum:",1,2,3,4); +GUI_TOOLTIP(uspex_gui.vacuumSize,"vacuumSize: Ch. 4.8 DEFAULT: 10.0\nVacuum size (Ang.) between neighbor atoms from adjacent unit cells.\nFor cluster, 2D-crystal, and surfaces only."); + GUI_TEXT_TABLE(table,uspex_gui.commandExecutable,uspex_gui._tmp_commandExecutable,"EXE:",2,3,3,4); +GUI_TOOLTIP(uspex_gui.commandExecutable,"commandExecutable: Ch. 4.8 DEFAULT: none\nCurrent optimisation step executable of submission script."); + GUI_OPEN_BUTTON_TABLE(table,button,load_abinito_exe_dialog,3,4,3,4); +/* line 4 */ + GUI_TEXT_TABLE(table,uspex_gui.job_path,uspex_gui.calc.job_path,"CALC:",0,1,4,5); +GUI_TOOLTIP(uspex_gui.job_path,"Select USPEX calculation folder.\nThe folder will contain result* folder."); + GUI_OPEN_BUTTON_TABLE(table,button,load_job_path,1,2,4,5); + GUI_TEXT_TABLE(table,uspex_gui.remoteFolder,uspex_gui.calc.remoteFolder,"REMT:",2,3,4,5); +GUI_TOOLTIP(uspex_gui.remoteFolder,"remoteFolder: Ch. 4.8 DEFAULT: none\nExecution folder on the distant computer."); + GUI_OPEN_BUTTON_TABLE(table,button,load_remote_folder,3,4,4,5); + + + +for(idx=5;idx<18;idx++) GUI_LABEL_TABLE(table," ",0,4,idx,idx+1); + + + + + +/* --- end page */ /*--------------------*/ /* page 4 -> ADVANCED */ /*--------------------*/ GUI_PAGE_NOTE(notebook,page,"ADVANCED"); -/* --- end frame */ +/* create a table in the page*/ + GUI_TABLE_NOTE(page,table,18,4); +/* --- Developers */ + GUI_LABEL_TABLE(table,"Developers",0,4,0,1); +/* line 1 */ + GUI_ENTRY_TABLE(table,uspex_gui.repeatForStatistics,uspex_gui.calc.repeatForStatistics,"%i","REPEAT:",0,1,1,2); +GUI_TOOLTIP(uspex_gui.repeatForStatistics,"repeatForStatistics: Ch. 4.12 DEFAULT: 1\nNumber of USPEX repeated job execution.\nFor default 1 value, no statistic is collected."); + GUI_ENTRY_TABLE(table,uspex_gui.stopFitness,uspex_gui.calc.stopFitness,"%.4f","STOP_FIT:",1,2,1,2); +GUI_TOOLTIP(uspex_gui.stopFitness,"stopFitness: Ch. 4.12 DEFAULT: none\nThe fitness value at which USPEX calculation will stop.\nSee also fitLimit in STRUCTURE page."); + GUI_ENTRY_TABLE(table,uspex_gui.fixRndSeed,uspex_gui.calc.fixRndSeed,"%i","RND_SEED:",2,3,1,2); +GUI_TOOLTIP(uspex_gui.fixRndSeed,"fixRndSeed: Ch. 4.12 DEFAULT: 0\nFor non-zero values, fix the random seed\nto check that for two USPEX calculations\nwith the same seed produce the same results."); + GUI_CHECK_TABLE(table,button,uspex_gui.calc.collectForces,NULL,"CollectForces",3,4,1,2);/*not calling anything*/ +GUI_TOOLTIP(button,"collectForces: Ch. 4.12 DEFAULT: FALSE\nCollect relaxation information from VASP calculation\n(energies, forces, positions, geometry, and stress)."); +/* --- Seldom */ + GUI_LABEL_TABLE(table,"Seldom",0,4,2,3); +/* line 3 */ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.ordering_active,NULL,"ordering",0,1,3,4);/*not calling anything*/ +GUI_TOOLTIP(button,"ordering_active: Ch. 4.12 DEFAULT: TRUE\nSwitch the \"biasing of variation operators by local order parameters\"."); + GUI_CHECK_TABLE(table,button,uspex_gui.calc.symmetrize,NULL,"symmetrize",1,2,3,4);/*not calling anything*/ +GUI_TOOLTIP(button,"symmetrize: Ch. 4.13 DEFAULT: FALSE\nTransform all structure to \"standard symmetry-adapted crystallografic setting\"."); + GUI_TEXT_TABLE(table,uspex_gui.valenceElectr,uspex_gui._tmp_valence_e,"VALENCE:",2,4,3,4); +GUI_TOOLTIP(uspex_gui.valenceElectr,"valenceElectr: Ch. 4.13 DEFAULT: AUTO\nNumber of valence electrons.\nOverrides the tabulated values."); +/* line 4 */ + GUI_ENTRY_TABLE(table,uspex_gui.percSliceShift,uspex_gui.calc.percSliceShift,"%.4f","SliceShift:",0,1,4,5); +GUI_TOOLTIP(uspex_gui.percSliceShift,"percSliceShift: Ch. 4.13 DEFAULT: 1.0\nProbability of shifting slabs."); + GUI_ENTRY_TABLE(table,uspex_gui.minSlice,uspex_gui.calc.minSlice,"%.4f","minSlice:",1,2,4,5); +GUI_TOOLTIP(uspex_gui.minSlice,"minSlice: Ch. 4.13 DEFAULT: N/A\nMinimal Slice thickness (Ang.).\nRecommended value is ~1 Ang."); + GUI_COMBOBOX_TABLE(table,uspex_gui.dynamicalBestHM,"DYN_HM:",2,4,4,5); + GUI_COMBOBOX_ADD(uspex_gui.dynamicalBestHM,"0 - NONE"); + GUI_COMBOBOX_ADD(uspex_gui.dynamicalBestHM,"1 - lowest Energy"); + GUI_COMBOBOX_ADD(uspex_gui.dynamicalBestHM,"2 - promote diversity"); +GUI_TOOLTIP(uspex_gui.dynamicalBestHM,"dynamicalBestHM: Ch. ?.? DEFAULT: 2\nSpecify if and how the number of surviving structure will vary.\nThis keyword has disapear in the 10.1 version of USPEX."); +/* line 5 */ + /*col 1: empty*/ + GUI_ENTRY_TABLE(table,uspex_gui.maxSlice,uspex_gui.calc.maxSlice,"%.4f","maxSlice:",1,2,5,6); +GUI_TOOLTIP(uspex_gui.minSlice,"maxSlice: Ch. 4.13 DEFAULT: N/A\nMaximum Slice thickness (Ang.).\nRecommended value is ~6 Ang."); + GUI_TEXT_TABLE(table,uspex_gui.softMutOnly,uspex_gui.calc.softMutOnly,"SoftMut:",2,4,5,6); +GUI_TOOLTIP(uspex_gui.softMutOnly,"softMutOnly: Ch. ?.? DEFAULT: 0\nWhich/how many generations are produced from soft mutation only.\nThis keyword has disapear in the 10.1 version of USPEX."); +/* line 6 */ + GUI_ENTRY_TABLE(table,uspex_gui.maxDistHeredity,uspex_gui.calc.maxDistHeredity,"%.4f","DistHer:",0,1,6,7); +GUI_TOOLTIP(uspex_gui.maxDistHeredity,"maxDistHeredity: Ch. 4.13 DEFAULT: 0.5\nMax fingerprint distance between structures chosen for heredity."); + GUI_ENTRY_TABLE(table,uspex_gui.numberparents,uspex_gui.calc.numberparents,"%i","NumP:",1,2,6,7); +GUI_TOOLTIP(uspex_gui.numberparents,"numberparents: Ch. 4.13 DEFAULT: 2\nNumber of parents chosen for heredity\nfor cluster calculation."); + + GUI_COMBOBOX_TABLE(table,uspex_gui.manyParents,"many_P:",2,4,6,7); + GUI_COMBOBOX_ADD(uspex_gui.manyParents,"0 - 2 parents, 1 slice each"); + GUI_COMBOBOX_ADD(uspex_gui.manyParents,"1 - n structures, 1 slice each"); + GUI_COMBOBOX_ADD(uspex_gui.manyParents,"2 - 2 structures, n slices, independants"); + GUI_COMBOBOX_ADD(uspex_gui.manyParents,"3 - 2 structures, n slices, fixed offset"); +GUI_TOOLTIP(uspex_gui.manyParents,"manyParents: Ch. 4.13 DEFAULT: 0\nDetermine if and how more slices\nand parents structures are chosen.\nFor large systems recommended\nsetting 3 may be beneficial."); +/* --- BoltzTraP */ + GUI_LABEL_TABLE(table,"BoltzTraP",0,4,7,8); +/* line 8 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.TE_goal,"Goal:",0,1,8,9); + GUI_COMBOBOX_ADD(uspex_gui.TE_goal,"ZT tensor trace"); + GUI_COMBOBOX_ADD(uspex_gui.TE_goal,"ZT_xx x component"); + GUI_COMBOBOX_ADD(uspex_gui.TE_goal,"ZT_yy y component"); + GUI_COMBOBOX_ADD(uspex_gui.TE_goal,"ZT_zz z component"); +GUI_TOOLTIP(uspex_gui.TE_goal,"TE_goal: Ch. 5.2 DEFAULT: ZT\nSet the component of ZT to be optimized."); + GUI_ENTRY_TABLE(table,uspex_gui.BoltzTraP_T_max,uspex_gui.calc.BoltzTraP_T_max,"%.4f","T_Max:",1,2,8,9); +GUI_TOOLTIP(uspex_gui.BoltzTraP_T_max,"BoltzTraP_T_max: Ch. 5.2 DEFAULT: 800.0\nMaximum BoltzTraP calculation temperature."); + GUI_ENTRY_TABLE(table,uspex_gui.BoltzTraP_T_delta,uspex_gui.calc.BoltzTraP_T_delta,"%.4f","T_delta:",2,3,8,9); +GUI_TOOLTIP(uspex_gui.BoltzTraP_T_delta,"BoltzTraP_T_delta: Ch. 5.2 DEFAULT: 50.0\nBoltzTraP calculation temperature increment."); + GUI_ENTRY_TABLE(table,uspex_gui.BoltzTraP_T_efcut,uspex_gui.calc.BoltzTraP_T_efcut,"%.4f","T_efcut:",3,4,8,9); +GUI_TOOLTIP(uspex_gui.BoltzTraP_T_efcut,"BoltzTraP_T_efcut: Ch. 5.2 DEFAULT: 0.15\nBoltzTraP calculation chemical potential (eV) interval."); +/* line 9 */ + GUI_TEXT_TABLE(table,uspex_gui.cmd_BoltzTraP,uspex_gui._tmp_cmd_BoltzTraP,"cmd:",0,1,9,10); +GUI_TOOLTIP(uspex_gui.cmd_BoltzTraP,"BoltzTraP software command/script (optional)."); +GUI_OPEN_BUTTON_TABLE(table,button,load_cmd_BoltzTraP,1,2,9,10); + GUI_ENTRY_TABLE(table,uspex_gui.TE_T_interest,uspex_gui.calc.TE_T_interest,"%.4f","T_target:",2,3,9,10); +GUI_TOOLTIP(uspex_gui.TE_T_interest,"TE_T_interest: Ch. 5.2 DEFAULT: 300.0Y\nTarget temperature to optimize thermoelectric efficiency."); + GUI_ENTRY_TABLE(table,uspex_gui.TE_threshold,uspex_gui.calc.TE_threshold,"%.4f","Threshold:",3,4,9,10); +GUI_TOOLTIP(uspex_gui.TE_threshold,"TE_threshold: Ch. 5.2 DEFAULT: 0.5\nStructures with a ZT figure of merit\nbelow this threshold will be discarded."); +/* --- Transition Path Sampling */ + GUI_LABEL_TABLE(table,"Transition Path Sampling",0,4,10,11); +/* line 11 */ + GUI_ENTRY_TABLE(table,uspex_gui.numIterations,uspex_gui.calc.numIterations,"%i","N_Iter:",0,1,11,12); +GUI_TOOLTIP(uspex_gui.numIterations,"numIterations: Ch. 6.2 DEFAULT: 1000\nMaximum number of TPS iterations."); + /*col 2: empty*/ + GUI_ENTRY_TABLE(table,uspex_gui.shiftRatio,uspex_gui.calc.shiftRatio,"%.4f","rShift:",2,3,11,12); +GUI_TOOLTIP(uspex_gui.shiftRatio,"shiftRatio: Ch. 6.2 DEFAULT: 0.1\nFraction of shooter-after-shifter operations."); + GUI_CHECK_TABLE(table,uspex_gui.orderParaType,uspex_gui.calc.orderParaType,NULL,"OP_TYPE",3,4,11,12);/*not calling anything*/ +GUI_TOOLTIP(uspex_gui.orderParaType,"orderParaType: Ch. 6.2 DEFAULT: none\nSelect if the method of order parameter calculation is:\nthe fingerprint method (TRUE)\na user-defined method (FALSE).\nContrary to USPEX lack of default, TRUE is pre-selected."); +/* line 12 */ + GUI_TEXT_TABLE(table,uspex_gui.speciesSymbol,uspex_gui.calc.speciesSymbol,"SpeciesSymbols:",0,2,12,13); +GUI_TOOLTIP(uspex_gui.speciesSymbol,"speciesSymbol: Ch. 6.2 DEFAULT: none\nIdentity of all chemical species (atoms/molecules)."); + GUI_TEXT_TABLE(table,uspex_gui.mass,uspex_gui._tmp_mass,"mass:",2,4,12,13); +GUI_TOOLTIP(uspex_gui.mass,"mass: Ch. 6.2 DEFAULT: Auto\nMass of each corresponding species."); +/* line 13 */ + GUI_ENTRY_TABLE(table,uspex_gui.amplitudeShoot_AB,uspex_gui.calc.amplitudeShoot[0],"%.4f","A(A->B):",0,1,13,14); +GUI_TOOLTIP(uspex_gui.amplitudeShoot_AB,"amplitudeShoot: Ch. 6.2 DEFAULT: 0.1\nMomentum amplitude for A->B shooting."); + GUI_ENTRY_TABLE(table,uspex_gui.amplitudeShoot_BA,uspex_gui.calc.amplitudeShoot[1],"%.4f","A(B->A):",1,2,13,14); +GUI_TOOLTIP(uspex_gui.amplitudeShoot_BA,"amplitudeShoot: Ch. 6.2 DEFAULT: 0.1\nMomentum amplitude for B->A shooting."); + GUI_ENTRY_TABLE(table,uspex_gui.magnitudeShoot_success,uspex_gui.calc.magnitudeShoot[0],"%.4f","M(success):",2,3,13,14); +GUI_TOOLTIP(uspex_gui.magnitudeShoot_success,"magnitudeShoot: Ch. 6.2 DEFAULT: 1.05\nAmplitude increasing factor on MD trajectory success."); + GUI_ENTRY_TABLE(table,uspex_gui.magnitudeShoot_failure,uspex_gui.calc.magnitudeShoot[1],"%.4f","M(failure):",3,4,13,14); +GUI_TOOLTIP(uspex_gui.magnitudeShoot_failure,"magnitudeShoot: Ch. 6.2 DEFAULT: 1.05\nAmplitude decreasing factor on MD trajectory failure."); +/* line 14 */ + GUI_TEXT_TABLE(table,uspex_gui.cmdOrderParameter,uspex_gui.calc.cmdOrderParameter,"cmdOP:",0,2,14,15); +GUI_TOOLTIP(uspex_gui.cmdOrderParameter,"cmdOrderParameter: Ch. 6.2 DEFAULT: none\nUser-defined command for order parameter calculation."); + GUI_OPEN_BUTTON_TABLE(table,button,load_cmd_OP,2,3,14,15); + GUI_ENTRY_TABLE(table,uspex_gui.opCriteria_start,uspex_gui.calc.opCriteria[0],"%.4f","SIM(start):",3,4,14,15); +GUI_TOOLTIP(uspex_gui.opCriteria_start,"opCriteria: Ch. 6.2 DEFAULT: none\nAllowable degree of similarity between starting states."); +/* line 15 */ + GUI_TEXT_TABLE(table,uspex_gui.cmdEnthalpyTemperature,uspex_gui.calc.cmdEnthalpyTemperature,"cmdET:",0,2,15,16); +GUI_TOOLTIP(uspex_gui.cmdEnthalpyTemperature,"cmdEnthalpyTemperature: Ch. 6.2 DEFAULT: Y\nUser-defined command for enthalpy/temperature\nextraction from the MD results."); + GUI_OPEN_BUTTON_TABLE(table,button,load_cmd_ET,2,3,15,16); + GUI_ENTRY_TABLE(table,uspex_gui.opCriteria_end,uspex_gui.calc.opCriteria[1],"%.4f","SIM(end):",3,4,15,16); +GUI_TOOLTIP(uspex_gui.opCriteria_end,"opCriteria: Ch. 6.2 DEFAULT: none\nAllowable degree of similarity between ending states."); +/* line 16 */ +GUI_TEXT_TABLE(table,uspex_gui.orderParameterFile,uspex_gui.calc.orderParameterFile,"OP_file:",0,1,16,17); +GUI_TOOLTIP(uspex_gui.orderParameterFile,"orderParameterFile: Ch. 6.2 DEFAULT: fp.dat\nOrder parameter history file."); +GUI_OPEN_BUTTON_TABLE(table,button,load_OP_file,1,2,16,17); +GUI_TEXT_TABLE(table,uspex_gui.enthalpyTemperatureFile,uspex_gui.calc.enthalpyTemperatureFile,"ET_file:",2,3,16,17); +GUI_TOOLTIP(uspex_gui.enthalpyTemperatureFile,"enthalpyTemperatureFile: Ch. 6.2 DEFAULT: HT.dat\nEnthalpy and temperature history file."); +GUI_OPEN_BUTTON_TABLE(table,button,load_ET_file,3,4,16,17); +/* line 17 */ +GUI_TEXT_TABLE(table,uspex_gui.trajectoryFile,uspex_gui.calc.trajectoryFile,"traj_file:",0,1,17,18); +GUI_TOOLTIP(uspex_gui.trajectoryFile,"trajectoryFile: Ch. 6.2 DEFAULT: traj.dat\nMD trajectory file."); +GUI_OPEN_BUTTON_TABLE(table,button,load_traj_file,1,2,17,18); +GUI_TEXT_TABLE(table,uspex_gui.MDrestartFile,uspex_gui.calc.MDrestartFile,"MD_file:",2,3,17,18); +GUI_TOOLTIP(uspex_gui.MDrestartFile,"MDrestartFile: Ch. 6.2 DEFAULT: traj.restart\nMD restart file."); +GUI_OPEN_BUTTON_TABLE(table,button,load_MDrestart_file,3,4,17,18); +/* initialize */ + GUI_COMBOBOX_SETUP(uspex_gui.dynamicalBestHM,2,uspex_dyn_HM_selected); + GUI_COMBOBOX_SETUP(uspex_gui.manyParents,0,uspex_manyParents_selected); + GUI_COMBOBOX_SETUP(uspex_gui.TE_goal,0,uspex_TE_goal_selected); +/* --- end page */ + + + + /*--------------------*/ /* page 5 -> SPECIFIC */ /*--------------------*/ GUI_PAGE_NOTE(notebook,page,"SPECIFIC"); -/* --- end frame */ +/* create a table in the page*/ + GUI_TABLE_NOTE(page,table,18,4); +/* --- Metadynamics */ + GUI_LABEL_TABLE(table,"Metadynamics",0,4,0,1); +/* line 1 */ + + +for(idx=1;idx<18;idx++) GUI_LABEL_TABLE(table," ",0,4,idx,idx+1); + + + +/* --- end page */ /* --- Outside of notebook */ GUI_FRAME_WINDOW(uspex_gui.window,frame); diff --git a/src/gui_uspex.h b/src/gui_uspex.h index 380bcf4..a36aece 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -31,11 +31,13 @@ The GNU GPL can also be found at http://www.gnu.org else uspex_gui.calc.value=NULL;\ }while(0) /*page numbers*/ -#define USPEX_PAGE_SET_I 1 -#define USPEX_PAGE_SET_II 2 -#define USPEX_PAGE_SPECIFICS 3 -#define USPEX_PAGE_ABINITIO 4 -#define USPEX_PAGE_EXEC 5 +#define USPEX_PAGE_SYSTEM 0 +#define USPEX_PAGE_STRUCTURES 1 +#define USPEX_PAGE_CALCULATION 2 +#define USPEX_PAGE_ADVANCED 3 +#define USPEX_PAGE_SPECIFIC 4 +/*fixed parameters*/ +#define USPEX_MAX_NUM_OPT_STEPS 32 /* gui structure */ struct uspex_calc_gui{ /*window information*/ @@ -56,6 +58,7 @@ struct uspex_calc_gui{ GUI_OBJ *_calctype_mol; GUI_OBJ *_calctype_var; GUI_OBJ *_calctype_mag; /*VER 10.1*/ + GUI_OBJ *_calctype_mag_2; /*VER 10.1*/ GUI_OBJ *optType; gboolean have_new_opt; /*VER 10.1*/ GUI_OBJ *new_optType; /*VER 10.1*/ @@ -136,6 +139,29 @@ struct uspex_calc_gui{ GUI_OBJ *splitInto; gchar *_tmp_splitInto; gboolean auto_lval; +/*4.7 restart*/ + /*unsupported*/ +/*4.8 Ab initio*/ + gdouble _tmp_num_opt_steps;/*because gtk_spin type is double*/ + GUI_OBJ *_num_opt_steps;/*usually determined indirectly*/ + gdouble _tmp_curr_step;/*because gtk_spin type is double*/ + GUI_OBJ *_curr_step; + gboolean _tmp_isfull; + GUI_OBJ *abinitioCode; + gdouble _tmp_KresolStart; + GUI_OBJ *KresolStart; + gdouble _tmp_vacuumSize; + GUI_OBJ *vacuumSize; + GUI_OBJ *numParallelCalcs; + gchar *_tmp_commandExecutable; + GUI_OBJ *commandExecutable; + GUI_OBJ *whichCluster; + GUI_OBJ *remoteFolder; + //PhaseDiagram is auto-sync + + + + /*4.9 fingerprint*/ GUI_OBJ *RmaxFing; GUI_OBJ *deltaFing; @@ -147,8 +173,38 @@ struct uspex_calc_gui{ /*4.11 spacegroup*/ GUI_OBJ *doSpaceGroup; GUI_OBJ *SymTolerance; +/*4.12 developers*/ + GUI_OBJ *repeatForStatistics; + GUI_OBJ *stopFitness; + GUI_OBJ *fixRndSeed; +// GUI_OBJ *collectForces; +/*4.13 seldom used*/ +// GUI_OBJ *ordering_active; +// GUI_OBJ *symmetrize; + gchar *_tmp_valence_e; + GUI_OBJ *valenceElectr; + GUI_OBJ *percSliceShift; + GUI_OBJ *dynamicalBestHM; + GUI_OBJ *softMutOnly; + GUI_OBJ *maxDistHeredity; + GUI_OBJ *manyParents; + GUI_OBJ *minSlice; + GUI_OBJ *maxSlice; + GUI_OBJ *numberparents; + +/*5.2 BoltzTraP*/ + GUI_OBJ *BoltzTraP_T_max; + GUI_OBJ *BoltzTraP_T_delta; + GUI_OBJ *BoltzTraP_T_efcut; + GUI_OBJ *TE_T_interest; + GUI_OBJ *TE_threshold; + GUI_OBJ *TE_goal; + gchar *_tmp_cmd_BoltzTraP;/*optional, and unused (for now)*/ + GUI_OBJ *cmd_BoltzTraP;/*optional, and unused (for now)*/ +/*5.3 Surfaces*/ +/*5.4 Clusters*/ /*5.5 variable composition*/ GUI_OBJ *firstGeneMax; GUI_OBJ *minAt; @@ -157,6 +213,28 @@ struct uspex_calc_gui{ GUI_OBJ *howManyTrans; gchar *_tmp_specificTrans; GUI_OBJ *specificTrans; +/*5.6 metadynamics*/ + + +/*6.2 Transition Path Sampling*/ + GUI_OBJ *numIterations; + GUI_OBJ *speciesSymbol; + gchar *_tmp_mass; + GUI_OBJ *mass; + GUI_OBJ *amplitudeShoot_AB; + GUI_OBJ *amplitudeShoot_BA; + GUI_OBJ *magnitudeShoot_success; + GUI_OBJ *magnitudeShoot_failure; + GUI_OBJ *shiftRatio; + GUI_OBJ *orderParaType; + GUI_OBJ *opCriteria_start; + GUI_OBJ *opCriteria_end; + GUI_OBJ *cmdOrderParameter; + GUI_OBJ *cmdEnthalpyTemperature; + GUI_OBJ *orderParameterFile; + GUI_OBJ *enthalpyTemperatureFile; + GUI_OBJ *trajectoryFile; + GUI_OBJ *MDrestartFile; /* CALCUL */ GUI_OBJ *job_uspex_exe; From 3180bbc86599f756fd2782d4da96e319eab49f0f Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 9 Nov 2018 18:26:07 +0900 Subject: [PATCH 40/56] gui_uspex: uspex parameters IV VER 10.1 --- src/gui_uspex.c | 435 ++++++++++++++++++++++++++++++++++++++++++++++-- src/gui_uspex.h | 51 +++++- 2 files changed, 466 insertions(+), 20 deletions(-) diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 043fee8..3b802f4 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -1497,6 +1497,270 @@ void load_traj_file(){ void load_MDrestart_file(){ } +/********************/ +/* select FullRelax */ +/********************/ +void uspex_relax_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 0: + uspex_gui.calc.FullRelax=0; + break; + case 1: + uspex_gui.calc.FullRelax=1; + break; + case 2: + /* fall through */ + default: + uspex_gui.calc.FullRelax=2; + } +} +/****************************************/ +/* load metadynamics starting structure */ +/****************************************/ +void load_meta_start_file(void){ + +} +/*****************************/ +/* select metadynamics model */ +/*****************************/ +void uspex_meta_model_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + GUI_LOCK(uspex_gui.meta_model_button); + break; + case 0: + /* fall through */ + default: + GUI_UNLOCK(uspex_gui.meta_model_button); + } +} +/*********************/ +/* update VCNEB Type */ +/*********************/ +void update_vcnebType(void){ + gchar *text; + gint type=uspex_gui.calc._vcnebtype_method*100; + if(uspex_gui.calc._vcnebtype_img_num) type+=10; + if(uspex_gui.calc._vcnebtype_spring) type+=1; + uspex_gui.calc.vcnebType=type; + /*update uspex_gui.vcnebType */ + text=g_strdup_printf("%3i",type); + GUI_ENTRY_TEXT(uspex_gui.vcnebType,text); + g_free(text); + /*consequences*/ + if(uspex_gui.calc._vcnebtype_img_num) GUI_UNLOCK(uspex_gui.VarPathLength); + else GUI_LOCK(uspex_gui.VarPathLength); + if(uspex_gui.calc._vcnebtype_spring){ + GUI_UNLOCK(uspex_gui.K_min); + GUI_UNLOCK(uspex_gui.K_max); + GUI_LOCK(uspex_gui.Kconstant); + }else{ + GUI_LOCK(uspex_gui.K_min); + GUI_LOCK(uspex_gui.K_max); + GUI_UNLOCK(uspex_gui.Kconstant); + } +} +/***********************/ +/* select VCNEB method */ +/***********************/ +void uspex_vcneb_method_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + uspex_gui.calc._vcnebtype_method=2; + break; + case 0: + /* fall through */ + default: + uspex_gui.calc._vcnebtype_method=1; + } + update_vcnebType(); +} +/******************************/ +/* select VCNEB optReadImages */ +/******************************/ +void uspex_ReadImg_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 0: + uspex_gui.calc.optReadImages=0; + break; + case 1: + uspex_gui.calc.optReadImages=1; + break; + case 2: + /* fall through */ + default: + uspex_gui.calc.optReadImages=2; + } +} +/*******************************/ +/* select VCNEB optimizer type */ +/*******************************/ +void uspex_optimizerType_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + uspex_gui.calc.optimizerType=2; + case 0: + /* fall through */ + default: + uspex_gui.calc.optimizerType=1; + } +} +/********************************/ +/* select VCNEB relaxation type */ +/********************************/ +void uspex_RelaxType_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 0: + uspex_gui.calc.optRelaxType=1; + break; + case 1: + uspex_gui.calc.optRelaxType=2; + break; + case 2: + /* fall through */ + default: + uspex_gui.calc.optRelaxType=3; + } +} +/*****************************/ +/* select VCNEB CI/DI method */ +/*****************************/ +void uspex_CIDI_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + uspex_gui.calc.optMethodCIDI=1; + break; + case 2: + uspex_gui.calc.optMethodCIDI=-1; + break; + case 3: + uspex_gui.calc.optMethodCIDI=2; + break; + case 0: + /* fall through */ + default: + uspex_gui.calc.optMethodCIDI=0; + } + /*consequences*/ + if(uspex_gui.calc.optMethodCIDI==0){ + GUI_LOCK(uspex_gui.startCIDIStep); + GUI_LOCK(uspex_gui.pickupImages); + }else{ + GUI_UNLOCK(uspex_gui.startCIDIStep); + GUI_UNLOCK(uspex_gui.pickupImages); + } +} +/***********************************/ +/* select VCNEB PATH output format */ +/***********************************/ +void uspex_FormatType_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 0: + uspex_gui.calc.FormatType=1; + break; + case 2: + uspex_gui.calc.FormatType=3; + break; + case 1: + /* fall through */ + default: + uspex_gui.calc.FormatType=2; + } +} +/*****************************/ +/* select VCNEB Images model */ +/*****************************/ +void uspex_img_model_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + GUI_LOCK(uspex_gui.img_model_button); + break; + case 0: + /* fall through */ + default: + GUI_UNLOCK(uspex_gui.img_model_button); + } +} +/*************************/ +/* load VCNEB Image file */ +/*************************/ +void load_img_model_file(void){ + +} +/**************************/ +/* select Molecular model */ +/**************************/ +void uspex_mol_model_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + GUI_UNLOCK(uspex_gui.mol_model_button); + GUI_UNLOCK(uspex_gui.num_mol); + break; + case 2: + GUI_LOCK(uspex_gui.mol_model_button); + GUI_LOCK(uspex_gui.num_mol); + break; + case 0: + /* fall through */ + default: + GUI_UNLOCK(uspex_gui.mol_model_button); + GUI_LOCK(uspex_gui.num_mol); + } +} +/*******************************/ +/* load molecular model/folder */ +/*******************************/ +void load_mod_model_file(void){ + +} +/**********************************/ +/* select surface substrate model */ +/**********************************/ +void uspex_substrate_model_selected(GUI_OBJ *w){ + gint index; + GUI_COMBOBOX_GET(w,index); + switch (index){ + case 1: + GUI_LOCK(uspex_gui.substrate_model_button); + break; + case 0: + /* fall through */ + default: + GUI_UNLOCK(uspex_gui.substrate_model_button); + } +} +/********************************/ +/* load surface substrate model */ +/********************************/ +void load_substrate_model_file(void){ + +} + + + + + + /************************/ @@ -2246,29 +2510,25 @@ GUI_TOOLTIP(uspex_gui.cmdEnthalpyTemperature,"cmdEnthalpyTemperature: Ch. 6.2 DE GUI_ENTRY_TABLE(table,uspex_gui.opCriteria_end,uspex_gui.calc.opCriteria[1],"%.4f","SIM(end):",3,4,15,16); GUI_TOOLTIP(uspex_gui.opCriteria_end,"opCriteria: Ch. 6.2 DEFAULT: none\nAllowable degree of similarity between ending states."); /* line 16 */ -GUI_TEXT_TABLE(table,uspex_gui.orderParameterFile,uspex_gui.calc.orderParameterFile,"OP_file:",0,1,16,17); + GUI_TEXT_TABLE(table,uspex_gui.orderParameterFile,uspex_gui.calc.orderParameterFile,"OP_file:",0,1,16,17); GUI_TOOLTIP(uspex_gui.orderParameterFile,"orderParameterFile: Ch. 6.2 DEFAULT: fp.dat\nOrder parameter history file."); -GUI_OPEN_BUTTON_TABLE(table,button,load_OP_file,1,2,16,17); -GUI_TEXT_TABLE(table,uspex_gui.enthalpyTemperatureFile,uspex_gui.calc.enthalpyTemperatureFile,"ET_file:",2,3,16,17); + GUI_OPEN_BUTTON_TABLE(table,button,load_OP_file,1,2,16,17); + GUI_TEXT_TABLE(table,uspex_gui.enthalpyTemperatureFile,uspex_gui.calc.enthalpyTemperatureFile,"ET_file:",2,3,16,17); GUI_TOOLTIP(uspex_gui.enthalpyTemperatureFile,"enthalpyTemperatureFile: Ch. 6.2 DEFAULT: HT.dat\nEnthalpy and temperature history file."); -GUI_OPEN_BUTTON_TABLE(table,button,load_ET_file,3,4,16,17); + GUI_OPEN_BUTTON_TABLE(table,button,load_ET_file,3,4,16,17); /* line 17 */ -GUI_TEXT_TABLE(table,uspex_gui.trajectoryFile,uspex_gui.calc.trajectoryFile,"traj_file:",0,1,17,18); + GUI_TEXT_TABLE(table,uspex_gui.trajectoryFile,uspex_gui.calc.trajectoryFile,"traj_file:",0,1,17,18); GUI_TOOLTIP(uspex_gui.trajectoryFile,"trajectoryFile: Ch. 6.2 DEFAULT: traj.dat\nMD trajectory file."); -GUI_OPEN_BUTTON_TABLE(table,button,load_traj_file,1,2,17,18); -GUI_TEXT_TABLE(table,uspex_gui.MDrestartFile,uspex_gui.calc.MDrestartFile,"MD_file:",2,3,17,18); + GUI_OPEN_BUTTON_TABLE(table,button,load_traj_file,1,2,17,18); + GUI_TEXT_TABLE(table,uspex_gui.MDrestartFile,uspex_gui.calc.MDrestartFile,"MD_file:",2,3,17,18); GUI_TOOLTIP(uspex_gui.MDrestartFile,"MDrestartFile: Ch. 6.2 DEFAULT: traj.restart\nMD restart file."); -GUI_OPEN_BUTTON_TABLE(table,button,load_MDrestart_file,3,4,17,18); + GUI_OPEN_BUTTON_TABLE(table,button,load_MDrestart_file,3,4,17,18); /* initialize */ GUI_COMBOBOX_SETUP(uspex_gui.dynamicalBestHM,2,uspex_dyn_HM_selected); GUI_COMBOBOX_SETUP(uspex_gui.manyParents,0,uspex_manyParents_selected); GUI_COMBOBOX_SETUP(uspex_gui.TE_goal,0,uspex_TE_goal_selected); /* --- end page */ - - - - /*--------------------*/ /* page 5 -> SPECIFIC */ /*--------------------*/ @@ -2278,13 +2538,156 @@ GUI_OPEN_BUTTON_TABLE(table,button,load_MDrestart_file,3,4,17,18); /* --- Metadynamics */ GUI_LABEL_TABLE(table,"Metadynamics",0,4,0,1); /* line 1 */ - - -for(idx=1;idx<18;idx++) GUI_LABEL_TABLE(table," ",0,4,idx,idx+1); + GUI_ENTRY_TABLE(table,uspex_gui.ExternalPressure,uspex_gui.calc.ExternalPressure,"%.4f","ExtP:",0,1,1,2); +GUI_TOOLTIP(uspex_gui.ExternalPressure,"ExternalPressure: Ch. 4.1, 5.6 DEFAULT: none\nExternal pressure (GPa) for calculation."); + GUI_ENTRY_TABLE(table,uspex_gui.maxVectorLength,uspex_gui.calc.maxVectorLength,"%.4f","MaxV:",1,2,1,2); +GUI_TOOLTIP(uspex_gui.maxVectorLength,"maxVectorLength: Ch. 5.6 DEFAULT: none\nAdd a correction force to keep cell length below this setting."); + GUI_ENTRY_TABLE(table,uspex_gui.GaussianWidth,uspex_gui.calc.GaussianWidth,"%.4f","GaussW:",2,3,1,2); +GUI_TOOLTIP(uspex_gui.GaussianWidth,"GaussianWidth: Ch. 5.6 DEFAULT: AUTO\nWidth of Gaussian added to PES to accelerate phase transition.\nRecommended values is 0.10~0.15L (L = minimum cell length)."); + GUI_ENTRY_TABLE(table,uspex_gui.GaussianHeight,uspex_gui.calc.GaussianHeight,"%.4f","GaussH:",3,4,1,2); +GUI_TOOLTIP(uspex_gui.GaussianHeight,"GaussianHeight: Ch. 5.6 DEFAULT: AUTO\nHeight of Gaussian added to PES to accelerate phase transition.\nRecommended values is L.dh^2.G with L = average cell length,\ndh = GaussW, and G = shear modulus."); +/* line 2 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.meta_model,"MODEL:",0,2,2,3); + GUI_COMBOBOX_ADD(uspex_gui.meta_model,"From POSCAR FILE"); + GUI_COMBOBOX_ADD(uspex_gui.meta_model,"UNDER CONSTRUCTION"); +GUI_TOOLTIP(uspex_gui.meta_model,"Select the model from which metadynamics is started.\nA good structure, relaxed at ExtP is necessary."); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.meta_model_button,load_meta_start_file,2,3,2,3); + GUI_COMBOBOX_TABLE(table,uspex_gui.FullRelax,"Relax:",3,4,2,3); + GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"0 - No full relaxation (fix cells)"); + GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"1 - Relax only the best structures"); + GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"2 - Relax all different structures"); +GUI_TOOLTIP(uspex_gui.FullRelax,"FullRelax: Ch. 5.6 DEFAULT: 2\nPerform full relaxation of which structures for analysis.\nRecommended value is 2."); +/* --- Particles Swarm optimization */ + GUI_LABEL_TABLE(table,"Particles Swarm optimization",0,4,3,4); +/* line 4 */ + /*col 1: empty*/ + GUI_ENTRY_TABLE(table,uspex_gui.PSO_softMut,uspex_gui.calc.PSO_softMut,"%.4f","SoftMut:",1,2,4,5); +GUI_TOOLTIP(uspex_gui.PSO_softMut,"PSO_softMut: Ch. 5.7 DEFAULT: 1\nSoft mutation weight."); + GUI_ENTRY_TABLE(table,uspex_gui.PSO_BestStruc,uspex_gui.calc.PSO_BestStruc,"%.4f","BestStruct:",2,3,4,5); +GUI_TOOLTIP(uspex_gui.PSO_BestStruc,"PSO_BestStruc: Ch. 5.7 DEFAULT: 1\nWeight of heredity with best position of a given PSO particle."); + GUI_ENTRY_TABLE(table,uspex_gui.PSO_BestEver,uspex_gui.calc.PSO_BestEver,"%.4f","BestEver:",3,4,4,5); +GUI_TOOLTIP(uspex_gui.PSO_BestEver,"PSO_BestEver: Ch. 5.7 DEFAULT: 1\nWeight of heredity with globally best PSO particle."); +/* --- Variable-cell nudged elastic band */ + GUI_LABEL_TABLE(table,"Variable-cell nudged elastic band",0,4,5,6); +/* line 6 */ + GUI_ENTRY_TABLE(table,uspex_gui.vcnebType,uspex_gui.calc.vcnebType,"%3i","VC-NEB:",0,1,6,7); +GUI_TOOLTIP(uspex_gui.vcnebType,"vcnebType: Ch. 6.1 DEFAULT: 110\nType of VC-NEB calculation."); + GUI_LOCK(uspex_gui.vcnebType);/*not directly modifiable*/ + GUI_COMBOBOX_TABLE(table,uspex_gui._vcnebtype_method,"Method:",1,2,6,7); + GUI_COMBOBOX_ADD(uspex_gui._vcnebtype_method,"1 - VC-NEB method"); + GUI_COMBOBOX_ADD(uspex_gui._vcnebtype_method,"2 - simple relaxation"); +GUI_TOOLTIP(uspex_gui._vcnebtype_method,"Choose between VC-NEB method and simple structure relaxation."); + GUI_CHECK_TABLE(table,uspex_gui._vcnebtype_img_num,uspex_gui.calc._vcnebtype_img_num,update_vcnebType,"Var_Image",2,3,6,7); +GUI_TOOLTIP(uspex_gui._vcnebtype_img_num,"Set whether number of images should be kept fixed."); + GUI_CHECK_TABLE(table,uspex_gui._vcnebtype_spring,uspex_gui.calc._vcnebtype_spring,update_vcnebType,"Var_Spring",3,4,6,7); +GUI_TOOLTIP(uspex_gui._vcnebtype_spring,"Set whether spring constants should be kept fixed."); +/* line 7 */ + GUI_ENTRY_TABLE(table,uspex_gui.numImages,uspex_gui.calc.numImages,"%i","N_Img:",0,1,7,8); +GUI_TOOLTIP(uspex_gui.numImages,"numImages: Ch. 6.1 DEFAULT: 9\nInitial number of images."); + GUI_COMBOBOX_TABLE(table,uspex_gui.optReadImages,"Read_Img:",1,2,7,8); + GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"0 - All structures are needed"); + GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"1 - Only initial and final"); + GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"2 - Initial and final + intermediates"); +GUI_TOOLTIP(uspex_gui.optReadImages,"optReadImages: Ch. 6.1 DEFAULT: 2\nSet the method for reading Images file."); + GUI_COMBOBOX_TABLE(table,uspex_gui.optimizerType,"Opt_Type:",2,3,7,8); + GUI_COMBOBOX_ADD(uspex_gui.optimizerType,"1 - Steepest Descent"); + GUI_COMBOBOX_ADD(uspex_gui.optimizerType,"2 - Fast Inertial Relaxation Engine"); +GUI_TOOLTIP(uspex_gui.optimizerType,"optimizerType: Ch. 6.1 DEFAULT: 1\nSelect the optimization algorithm (SD or FIRE)."); + GUI_COMBOBOX_TABLE(table,uspex_gui.optRelaxType,"RelaxType:",3,4,7,8); + GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"1 - fixed cell, positions relaxed (=NEB)"); + GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"2 - cell lattice only (only for testing)"); + GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"3 - full, cell and positions relaxation."); +GUI_TOOLTIP(uspex_gui.optRelaxType,"optRelaxType: Ch. 6.1 DEFAULT: 3>\nStructure relaxation mode."); +/* line 8 */ + GUI_ENTRY_TABLE(table,uspex_gui.numSteps,uspex_gui.calc.numSteps,"%4i","N_Step:",0,1,8,9); +GUI_TOOLTIP(uspex_gui.numSteps,"numSteps: Ch. 6.1 DEFAULT: 600\nMaximum VC-NEB step iterations.\nA value of at least 500 is recommended."); + GUI_ENTRY_TABLE(table,uspex_gui.dt,uspex_gui.calc.dt,"%.4f","dt:",1,2,8,9); +GUI_TOOLTIP(uspex_gui.dt,"dt: Ch. 6.1 DEFAULT: 0.05\nTime step for structure relaxation."); + GUI_ENTRY_TABLE(table,uspex_gui.ConvThreshold,uspex_gui.calc.ConvThreshold,"%.4f","Conv:",2,3,8,9); +GUI_TOOLTIP(uspex_gui.ConvThreshold,"ConvThreshold: Ch. 6.1 DEFAULT: 0.003\nHalting condition (ev/Ang.) for RMS forces on images."); + GUI_ENTRY_TABLE(table,uspex_gui.VarPathLength,uspex_gui.calc.VarPathLength,"%.4f","PathLength:",3,4,8,9); +GUI_TOOLTIP(uspex_gui.VarPathLength,"VarPathLength: Ch. 6.1 DEFAULT: AUTO\nCriterion to determine image creation/deletion for variable image method.\nif L>1.5*criterion image is added\nif L<0.5*criterion image is deleted\nL=length between two neighbor images."); +/* line 9 */ + GUI_CHECK_TABLE(table,uspex_gui.optFreezing,uspex_gui.calc.optFreezing,NULL,"Freeze_Img",0,1,9,10);/*not calling anything*/ +GUI_TOOLTIP(uspex_gui.optFreezing,"optFreezing: Ch. 6.1 DEFAULT: FALSE\nActivate freezing of Image structure when ConvThreshold is reached."); + GUI_ENTRY_TABLE(table,uspex_gui.K_min,uspex_gui.calc.K_min,"%.4f","Kmin:",1,2,9,10); +GUI_TOOLTIP(uspex_gui.K_min,"K_min: Ch. 6.1 DEFAULT: 5\nMinimum spring constant (eV/Ang.^2)."); + GUI_ENTRY_TABLE(table,uspex_gui.K_max,uspex_gui.calc.K_max,"%.4f","Kmax:",2,3,9,10); +GUI_TOOLTIP(uspex_gui.K_max,"K_max: Ch. 6.1 DEFAULT: 5\nMaximum spring constant (eV/Ang.^2)."); + GUI_ENTRY_TABLE(table,uspex_gui.Kconstant,uspex_gui.calc.Kconstant,"%.4f","Kcte:",3,4,9,10); +GUI_TOOLTIP(uspex_gui.Kconstant,"Kconstant: Ch. 6.1 DEFAULT: 5\nFixed spring constant (eV/Ang.^2)."); +/* line 10 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.optMethodCIDI,"CI/DI:",0,1,10,11); + GUI_COMBOBOX_ADD(uspex_gui.optMethodCIDI," 0 - No CI/DI method will be used"); + GUI_COMBOBOX_ADD(uspex_gui.optMethodCIDI," 1 - single CI on highest energy TS"); + GUI_COMBOBOX_ADD(uspex_gui.optMethodCIDI,"-1 - Single DI on lowest energy LM"); + GUI_COMBOBOX_ADD(uspex_gui.optMethodCIDI," 2 - Multi-CI/DI on provided TS/LM"); +GUI_TOOLTIP(uspex_gui.optMethodCIDI,"optMethodCIDI: Ch. 6.1 DEFAULT: 0\nOption for Climbing-Image (CI) and Descending-Image (DI)."); + GUI_ENTRY_TABLE(table,uspex_gui.startCIDIStep,uspex_gui.calc.startCIDIStep,"%i","Start CI/DI:",1,2,10,11); +GUI_TOOLTIP(uspex_gui.startCIDIStep,"startCIDIStep: Ch. 6.1 DEFAULT: 100\nStarting step for CI/DI method."); + GUI_TEXT_TABLE(table,uspex_gui.pickupImages,uspex_gui._tmp_pickupImages,"Pickup:",2,3,10,11); +GUI_TOOLTIP(uspex_gui.pickupImages,"pickupImages: Ch. 6.1 DEFAULT: AUTO\nNumber/which images to be picked up for CI/DI method."); + GUI_COMBOBOX_TABLE(table,uspex_gui.FormatType,"Format:",3,4,10,11); + GUI_COMBOBOX_ADD(uspex_gui.FormatType,"1 - XCRYSTDENS format (.xsf)"); + GUI_COMBOBOX_ADD(uspex_gui.FormatType,"2 - VASP v5 (POSCAR) format."); + GUI_COMBOBOX_ADD(uspex_gui.FormatType,"3 - XYZ format with lattice."); +GUI_TOOLTIP(uspex_gui.FormatType,"FormatType: Ch. 6.1 DEFAULT: 2\nFormat of structures in PATH output directory."); +/* line 11 */ + GUI_ENTRY_TABLE(table,uspex_gui.PrintStep,uspex_gui.calc.PrintStep,"%i","PrintStep:",0,1,11,12); +GUI_TOOLTIP(uspex_gui.PrintStep,"PrintStep: Ch. 6.1 DEFAULT: 1\nSave restart file every PrintStep times."); + GUI_COMBOBOX_TABLE(table,uspex_gui.img_model,"Model:",1,3,11,12); + GUI_COMBOBOX_ADD(uspex_gui.img_model,"From Images file"); + GUI_COMBOBOX_ADD(uspex_gui.img_model,"UNDER CONSTRUCTION"); +GUI_TOOLTIP(uspex_gui.img_model,"Select the original Images model."); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.img_model_button,load_img_model_file,3,4,11,12); +/* --- Molecules */ + GUI_LABEL_TABLE(table,"Molecules",0,4,12,13); +/* line 13 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.mol_model,"MODEL:",0,2,13,14); + GUI_COMBOBOX_ADD(uspex_gui.mol_model,"From MOL_1 file"); + GUI_COMBOBOX_ADD(uspex_gui.mol_model,"From MOL_x folder"); + GUI_COMBOBOX_ADD(uspex_gui.mol_model,"UNDER CONSTRUCTION"); +GUI_TOOLTIP(uspex_gui.mol_model,"Select the model(s) for molecular calculation."); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.mol_model_button,load_mod_model_file,2,3,13,14); + GUI_ENTRY_TABLE(table,uspex_gui.num_mol,uspex_gui.calc._nmolecules,"%i","N_Mol:",3,4,13,14); +GUI_TOOLTIP(uspex_gui.num_mol,"number of molecules in the system."); +/* --- Surfaces */ + GUI_LABEL_TABLE(table,"Surfaces",0,4,14,15); +/* line 15 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.substrate_model,"MODEL:",0,2,15,16); + GUI_COMBOBOX_ADD(uspex_gui.substrate_model,"From VASP5 POSCAR file"); + GUI_COMBOBOX_ADD(uspex_gui.substrate_model,"UNDER CONSTRUCTION"); +GUI_TOOLTIP(uspex_gui.substrate_model,"Select the model to use as a substrate\nie. without buffer, surface, and vacuum region."); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.substrate_model_button,load_substrate_model_file,2,3,15,16); +GUI_ENTRY_TABLE(table,uspex_gui.thicknessS,uspex_gui.calc.thicknessS,"%.4f","S_thick:",3,4,15,16); +GUI_TOOLTIP(uspex_gui.thicknessS,"thicknessS: Ch. 5.3 DEFAULT: 2.0\nThickness (Ang.) of the surface region."); +/* line 16 */ + GUI_TEXT_TABLE(table,uspex_gui.StoichiometryStart,uspex_gui._tmp_StoichiometryStart,"Stoichio:",0,2,16,17); +GUI_TOOLTIP(uspex_gui.StoichiometryStart,"StoichiometryStart: Ch. 5.3 DEFAULT: ?\nDefine the initial stoichiometry of the bulk."); + GUI_ENTRY_TABLE(table,uspex_gui.reconstruct,uspex_gui.calc.reconstruct,"%i","N_Surf:",2,3,16,17); +GUI_TOOLTIP(uspex_gui.reconstruct,"reconstruct: Ch. 5.3 DEFAULT: 1\nNumber of replication of the surface cell."); + GUI_ENTRY_TABLE(table,uspex_gui.thicknessB,uspex_gui.calc.thicknessB,"%.4f","B_thick:",3,4,16,17); +GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (Ang.) of the buffer region."); +/* line 17: empty*/ + GUI_LABEL_TABLE(table," ",0,4,17,18); +/* initialize */ + GUI_COMBOBOX_SETUP(uspex_gui.FullRelax,2,uspex_relax_selected); + GUI_COMBOBOX_SETUP(uspex_gui.meta_model,0,uspex_meta_model_selected); + GUI_COMBOBOX_SETUP(uspex_gui._vcnebtype_method,0,uspex_vcneb_method_selected); + GUI_COMBOBOX_SETUP(uspex_gui.optReadImages,2,uspex_ReadImg_selected); + GUI_COMBOBOX_SETUP(uspex_gui.optimizerType,0,uspex_optimizerType_selected); + GUI_COMBOBOX_SETUP(uspex_gui.optRelaxType,2,uspex_RelaxType_selected); + GUI_COMBOBOX_SETUP(uspex_gui.optMethodCIDI,0,uspex_CIDI_selected); + GUI_COMBOBOX_SETUP(uspex_gui.FormatType,0,uspex_FormatType_selected); + uspex_CIDI_selected(uspex_gui.optMethodCIDI); + GUI_COMBOBOX_SETUP(uspex_gui.img_model,0,uspex_img_model_selected); + update_vcnebType(); + GUI_COMBOBOX_SETUP(uspex_gui.mol_model,0,uspex_mol_model_selected); + GUI_COMBOBOX_SETUP(uspex_gui.substrate_model,0,uspex_substrate_model_selected); +/* --- end page */ -/* --- end page */ /* --- Outside of notebook */ GUI_FRAME_WINDOW(uspex_gui.window,frame); diff --git a/src/gui_uspex.h b/src/gui_uspex.h index a36aece..ffcd812 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -192,8 +192,10 @@ struct uspex_calc_gui{ GUI_OBJ *maxSlice; GUI_OBJ *numberparents; - - +/*5.1 molecular*/ + GUI_OBJ *mol_model;/*additional*/ + GUI_OBJ *mol_model_button;/*additional*/ + GUI_OBJ *num_mol;/*additional*/ /*5.2 BoltzTraP*/ GUI_OBJ *BoltzTraP_T_max; GUI_OBJ *BoltzTraP_T_delta; @@ -204,6 +206,13 @@ struct uspex_calc_gui{ gchar *_tmp_cmd_BoltzTraP;/*optional, and unused (for now)*/ GUI_OBJ *cmd_BoltzTraP;/*optional, and unused (for now)*/ /*5.3 Surfaces*/ + GUI_OBJ *thicknessS; + GUI_OBJ *thicknessB; + GUI_OBJ *reconstruct; + gchar *_tmp_StoichiometryStart; + GUI_OBJ *StoichiometryStart;/*almost undocumented*/ + GUI_OBJ *substrate_model;/*additional*/ + GUI_OBJ *substrate_model_button;/*additional*/ /*5.4 Clusters*/ /*5.5 variable composition*/ GUI_OBJ *firstGeneMax; @@ -214,8 +223,42 @@ struct uspex_calc_gui{ gchar *_tmp_specificTrans; GUI_OBJ *specificTrans; /*5.6 metadynamics*/ - - + GUI_OBJ *ExternalPressure; + GUI_OBJ *GaussianWidth; + GUI_OBJ *GaussianHeight; + GUI_OBJ *FullRelax; + GUI_OBJ *maxVectorLength; + GUI_OBJ *meta_model;/*additional*/ + GUI_OBJ *meta_model_button;/*additional*/ +/*5.7 Particle swarn optimization*/ + GUI_OBJ *PSO_softMut; + GUI_OBJ *PSO_BestStruc; + GUI_OBJ *PSO_BestEver; +/*6.1 Variable-Cell Nudged Elastic Band */ + GUI_OBJ *vcnebType; + GUI_OBJ *_vcnebtype_method; + GUI_OBJ *_vcnebtype_img_num; + GUI_OBJ *_vcnebtype_spring; + GUI_OBJ *numImages; + GUI_OBJ *numSteps; + GUI_OBJ *optReadImages; + GUI_OBJ *optimizerType; + GUI_OBJ *optRelaxType; + GUI_OBJ *dt; + GUI_OBJ *ConvThreshold; + GUI_OBJ *VarPathLength; + GUI_OBJ *K_min; + GUI_OBJ *K_max; + GUI_OBJ *Kconstant; + GUI_OBJ *optFreezing; + GUI_OBJ *optMethodCIDI; + GUI_OBJ *startCIDIStep; + gchar *_tmp_pickupImages; + GUI_OBJ *pickupImages; + GUI_OBJ *FormatType; + GUI_OBJ *PrintStep; + GUI_OBJ *img_model;/*additional*/ + GUI_OBJ *img_model_button;/*additional*/ /*6.2 Transition Path Sampling*/ GUI_OBJ *numIterations; GUI_OBJ *speciesSymbol; From 559affda1154d6b6f4609fa46a72087f9cf853d4 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 9 Nov 2018 21:33:52 +0900 Subject: [PATCH 41/56] gui_uspex: uspex parameters V VER 10.1 --- src/gui_defs.h | 8 ++ src/gui_uspex.c | 304 +++++++++++++++++++++++++++++++++++++----------- src/gui_uspex.h | 24 ++-- 3 files changed, 258 insertions(+), 78 deletions(-) diff --git a/src/gui_defs.h b/src/gui_defs.h index 12cb4b3..d5d7000 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -144,6 +144,14 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_NOTE_PAGE_NUMBER(notebook,number) do{\ number = gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook));\ }while(0) +/*hide a page*/ +#define GUI_NOTE_PAGE_HIDE(page) do{\ + gtk_widget_hide(page);\ +}while(0) +/*show a page*/ +#define GUI_NOTE_PAGE_SHOW(page) do{\ + gtk_widget_show(page);\ +}while(0) /*******************/ /* FRAME INTERFACE */ /*******************/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 3b802f4..bb8dab0 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -309,6 +309,20 @@ void uspex_path_dialog(void){ } GUI_KILL_OPEN_DIALOG(file_chooser); } +/***************************/ +/* show/hide specific page */ +/***************************/ +void update_specific(void){ + gboolean hide_specific=TRUE; + if((uspex_gui.calc.calculationMethod==US_CM_META) + ||(uspex_gui.calc.calculationMethod==US_CM_VCNEB) + ||(uspex_gui.calc.calculationMethod==US_CM_PSO)) + hide_specific=FALSE; + hide_specific&=(uspex_gui.calc._calctype_mol==FALSE); + hide_specific&=(uspex_gui.calc._calctype_dim!=2); + if(!hide_specific) GUI_NOTE_PAGE_SHOW(uspex_gui.specific_page); + else GUI_NOTE_PAGE_HIDE(uspex_gui.specific_page); +} /**************************************************/ /* refresh the GUI with value from uspex_gui.calc */ /**************************************************/ @@ -322,22 +336,145 @@ void uspex_gui_refresh(){ void uspex_method_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); + /*consequences*/ +/*META*/ + GUI_LOCK(uspex_gui.ExternalPressure); + GUI_LOCK(uspex_gui.GaussianWidth); + GUI_LOCK(uspex_gui.GaussianHeight); + GUI_LOCK(uspex_gui.FullRelax); + GUI_LOCK(uspex_gui.maxVectorLength); + GUI_LOCK(uspex_gui.meta_model); + GUI_LOCK(uspex_gui.meta_model_button); +/*VCNEB*/ + GUI_LOCK(uspex_gui.vcnebType); + GUI_LOCK(uspex_gui._vcnebtype_method); + GUI_LOCK(uspex_gui._vcnebtype_img_num); + GUI_LOCK(uspex_gui._vcnebtype_spring); + GUI_LOCK(uspex_gui.numImages); + GUI_LOCK(uspex_gui.numSteps); + GUI_LOCK(uspex_gui.optReadImages); + GUI_LOCK(uspex_gui.optimizerType); + GUI_LOCK(uspex_gui.optRelaxType); + GUI_LOCK(uspex_gui.dt); + GUI_LOCK(uspex_gui.ConvThreshold); + GUI_LOCK(uspex_gui.VarPathLength); + GUI_LOCK(uspex_gui.K_min); + GUI_LOCK(uspex_gui.K_max); + GUI_LOCK(uspex_gui.Kconstant); + GUI_LOCK(uspex_gui.optFreezing); + GUI_LOCK(uspex_gui.optMethodCIDI); + GUI_LOCK(uspex_gui.startCIDIStep); + GUI_LOCK(uspex_gui.pickupImages); + GUI_LOCK(uspex_gui.FormatType); + GUI_LOCK(uspex_gui.PrintStep); + GUI_LOCK(uspex_gui.img_model); + GUI_LOCK(uspex_gui.img_model_button); +/*PSO*/ + GUI_LOCK(uspex_gui.PSO_softMut); + GUI_LOCK(uspex_gui.PSO_BestStruc); + GUI_LOCK(uspex_gui.PSO_BestEver); +/*TPS*/ + GUI_LOCK(uspex_gui.numIterations); + GUI_LOCK(uspex_gui.speciesSymbol); + GUI_LOCK(uspex_gui.mass); + GUI_LOCK(uspex_gui.amplitudeShoot_AB); + GUI_LOCK(uspex_gui.amplitudeShoot_BA); + GUI_LOCK(uspex_gui.magnitudeShoot_success); + GUI_LOCK(uspex_gui.magnitudeShoot_failure); + GUI_LOCK(uspex_gui.shiftRatio); + GUI_LOCK(uspex_gui.orderParaType); + GUI_LOCK(uspex_gui.opCriteria_start); + GUI_LOCK(uspex_gui.opCriteria_end); + GUI_LOCK(uspex_gui.cmdOrderParameter); + GUI_LOCK(uspex_gui.cmdOrderParameter_button); + GUI_LOCK(uspex_gui.cmdEnthalpyTemperature); + GUI_LOCK(uspex_gui.cmdEnthalpyTemperature_button); + GUI_LOCK(uspex_gui.orderParameterFile); + GUI_LOCK(uspex_gui.orderParameterFile_button); + GUI_LOCK(uspex_gui.enthalpyTemperatureFile); + GUI_LOCK(uspex_gui.enthalpyTemperatureFile_button); + GUI_LOCK(uspex_gui.trajectoryFile); + GUI_LOCK(uspex_gui.trajectoryFile_button); + GUI_LOCK(uspex_gui.MDrestartFile); + GUI_LOCK(uspex_gui.MDrestartFile_button); + /*check method*/ switch (index){ case 0://USPEX uspex_gui.calc.calculationMethod = US_CM_USPEX;break; case 1://META - uspex_gui.calc.calculationMethod = US_CM_META;break; + uspex_gui.calc.calculationMethod = US_CM_META; + GUI_UNLOCK(uspex_gui.ExternalPressure); + GUI_UNLOCK(uspex_gui.GaussianWidth); + GUI_UNLOCK(uspex_gui.GaussianHeight); + GUI_UNLOCK(uspex_gui.FullRelax); + GUI_UNLOCK(uspex_gui.maxVectorLength); + GUI_UNLOCK(uspex_gui.meta_model); + GUI_UNLOCK(uspex_gui.meta_model_button); + break; case 2://VCNEB - uspex_gui.calc.calculationMethod = US_CM_VCNEB;break; + uspex_gui.calc.calculationMethod = US_CM_VCNEB; + GUI_UNLOCK(uspex_gui.vcnebType); + GUI_UNLOCK(uspex_gui._vcnebtype_method); + GUI_UNLOCK(uspex_gui._vcnebtype_img_num); + GUI_UNLOCK(uspex_gui._vcnebtype_spring); + GUI_UNLOCK(uspex_gui.numImages); + GUI_UNLOCK(uspex_gui.numSteps); + GUI_UNLOCK(uspex_gui.optReadImages); + GUI_UNLOCK(uspex_gui.optimizerType); + GUI_UNLOCK(uspex_gui.optRelaxType); + GUI_UNLOCK(uspex_gui.dt); + GUI_UNLOCK(uspex_gui.ConvThreshold); + GUI_UNLOCK(uspex_gui.VarPathLength); + GUI_UNLOCK(uspex_gui.K_min); + GUI_UNLOCK(uspex_gui.K_max); + GUI_UNLOCK(uspex_gui.Kconstant); + GUI_UNLOCK(uspex_gui.optFreezing); + GUI_UNLOCK(uspex_gui.optMethodCIDI); + GUI_UNLOCK(uspex_gui.startCIDIStep); + GUI_UNLOCK(uspex_gui.pickupImages); + GUI_UNLOCK(uspex_gui.FormatType); + GUI_UNLOCK(uspex_gui.PrintStep); + GUI_UNLOCK(uspex_gui.img_model); + GUI_UNLOCK(uspex_gui.img_model_button); + break; case 3://PSO - uspex_gui.calc.calculationMethod = US_CM_PSO;break; + uspex_gui.calc.calculationMethod = US_CM_PSO; + GUI_UNLOCK(uspex_gui.PSO_softMut); + GUI_UNLOCK(uspex_gui.PSO_BestStruc); + GUI_UNLOCK(uspex_gui.PSO_BestEver); + break; case 4://TPS - uspex_gui.calc.calculationMethod = US_CM_TPS;break; - case 5://MINHOP + uspex_gui.calc.calculationMethod = US_CM_TPS; + GUI_UNLOCK(uspex_gui.numIterations); + GUI_UNLOCK(uspex_gui.speciesSymbol); + GUI_UNLOCK(uspex_gui.mass); + GUI_UNLOCK(uspex_gui.amplitudeShoot_AB); + GUI_UNLOCK(uspex_gui.amplitudeShoot_BA); + GUI_UNLOCK(uspex_gui.magnitudeShoot_success); + GUI_UNLOCK(uspex_gui.magnitudeShoot_failure); + GUI_UNLOCK(uspex_gui.shiftRatio); + GUI_UNLOCK(uspex_gui.orderParaType); + GUI_UNLOCK(uspex_gui.opCriteria_start); + GUI_UNLOCK(uspex_gui.opCriteria_end); + GUI_UNLOCK(uspex_gui.cmdOrderParameter); + GUI_UNLOCK(uspex_gui.cmdOrderParameter_button); + GUI_UNLOCK(uspex_gui.cmdEnthalpyTemperature); + GUI_UNLOCK(uspex_gui.cmdEnthalpyTemperature_button); + GUI_UNLOCK(uspex_gui.orderParameterFile); + GUI_UNLOCK(uspex_gui.orderParameterFile_button); + GUI_UNLOCK(uspex_gui.enthalpyTemperatureFile); + GUI_UNLOCK(uspex_gui.enthalpyTemperatureFile_button); + GUI_UNLOCK(uspex_gui.trajectoryFile); + GUI_UNLOCK(uspex_gui.trajectoryFile_button); + GUI_UNLOCK(uspex_gui.MDrestartFile); + GUI_UNLOCK(uspex_gui.MDrestartFile_button); + break; + case 5://MINHOP -- no specific interface uspex_gui.calc.calculationMethod = US_CM_MINHOP;break; default://UNKNOWN uspex_gui.calc.calculationMethod = US_CM_UNKNOWN; } + update_specific(); } /*****************************/ /* selecting calculationType */ @@ -345,6 +482,19 @@ void uspex_method_selected(GUI_OBJ *w){ void uspex_type_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); + /*consequences*/ +/*molecular*/ + GUI_LOCK(uspex_gui.mol_model); + GUI_LOCK(uspex_gui.mol_model_button); + GUI_LOCK(uspex_gui.num_mol); +/*Surfaces*/ + GUI_LOCK(uspex_gui.thicknessS); + GUI_LOCK(uspex_gui.thicknessB); + GUI_LOCK(uspex_gui.reconstruct); + GUI_LOCK(uspex_gui.StoichiometryStart); + GUI_LOCK(uspex_gui.substrate_model); + GUI_LOCK(uspex_gui.substrate_model_button); + /*check type*/ switch (index){ case 1://s300 uspex_gui.calc.calculationType=US_CT_s300; @@ -373,6 +523,9 @@ void uspex_type_selected(GUI_OBJ *w){ uspex_gui.calc._calctype_mol=TRUE; uspex_gui.calc._calctype_var=FALSE; uspex_gui.calc._calctype_mag=FALSE; + GUI_UNLOCK(uspex_gui.mol_model); + GUI_UNLOCK(uspex_gui.mol_model_button); + GUI_UNLOCK(uspex_gui.num_mol); break; case 5://311 uspex_gui.calc.calculationType=US_CT_311; @@ -380,6 +533,9 @@ void uspex_type_selected(GUI_OBJ *w){ uspex_gui.calc._calctype_mol=TRUE; uspex_gui.calc._calctype_var=TRUE; uspex_gui.calc._calctype_mag=FALSE; + GUI_UNLOCK(uspex_gui.mol_model); + GUI_UNLOCK(uspex_gui.mol_model_button); + GUI_UNLOCK(uspex_gui.num_mol); break; case 6://000 uspex_gui.calc.calculationType=US_CT_000; @@ -401,6 +557,9 @@ void uspex_type_selected(GUI_OBJ *w){ uspex_gui.calc._calctype_mol=TRUE; uspex_gui.calc._calctype_var=FALSE; uspex_gui.calc._calctype_mag=FALSE; + GUI_UNLOCK(uspex_gui.mol_model); + GUI_UNLOCK(uspex_gui.mol_model_button); + GUI_UNLOCK(uspex_gui.num_mol); break; case 9://200 uspex_gui.calc.calculationType=US_CT_200; @@ -408,6 +567,12 @@ void uspex_type_selected(GUI_OBJ *w){ uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=FALSE; uspex_gui.calc._calctype_mag=FALSE; + GUI_UNLOCK(uspex_gui.thicknessS); + GUI_UNLOCK(uspex_gui.thicknessB); + GUI_UNLOCK(uspex_gui.reconstruct); + GUI_UNLOCK(uspex_gui.StoichiometryStart); + GUI_UNLOCK(uspex_gui.substrate_model); + GUI_UNLOCK(uspex_gui.substrate_model_button); break; case 10://s200 uspex_gui.calc.calculationType=US_CT_s200; @@ -415,6 +580,12 @@ void uspex_type_selected(GUI_OBJ *w){ uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=FALSE; uspex_gui.calc._calctype_mag=TRUE; + GUI_UNLOCK(uspex_gui.thicknessS); + GUI_UNLOCK(uspex_gui.thicknessB); + GUI_UNLOCK(uspex_gui.reconstruct); + GUI_UNLOCK(uspex_gui.StoichiometryStart); + GUI_UNLOCK(uspex_gui.substrate_model); + GUI_UNLOCK(uspex_gui.substrate_model_button); break; case 11://201 uspex_gui.calc.calculationType=US_CT_201; @@ -422,6 +593,12 @@ void uspex_type_selected(GUI_OBJ *w){ uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=TRUE; uspex_gui.calc._calctype_mag=FALSE; + GUI_UNLOCK(uspex_gui.thicknessS); + GUI_UNLOCK(uspex_gui.thicknessB); + GUI_UNLOCK(uspex_gui.reconstruct); + GUI_UNLOCK(uspex_gui.StoichiometryStart); + GUI_UNLOCK(uspex_gui.substrate_model); + GUI_UNLOCK(uspex_gui.substrate_model_button); break; case 12://s201 uspex_gui.calc.calculationType=US_CT_s201; @@ -429,6 +606,12 @@ void uspex_type_selected(GUI_OBJ *w){ uspex_gui.calc._calctype_mol=FALSE; uspex_gui.calc._calctype_var=TRUE; uspex_gui.calc._calctype_mag=TRUE; + GUI_UNLOCK(uspex_gui.thicknessS); + GUI_UNLOCK(uspex_gui.thicknessB); + GUI_UNLOCK(uspex_gui.reconstruct); + GUI_UNLOCK(uspex_gui.StoichiometryStart); + GUI_UNLOCK(uspex_gui.substrate_model); + GUI_UNLOCK(uspex_gui.substrate_model_button); break; case 13://-200 uspex_gui.calc.calculationType=US_CT_m200; @@ -460,6 +643,7 @@ void uspex_type_selected(GUI_OBJ *w){ else GUI_TOGGLE_OFF(uspex_gui._calctype_var); if(uspex_gui.calc._calctype_mag) GUI_TOGGLE_ON(uspex_gui._calctype_mag); else GUI_TOGGLE_OFF(uspex_gui._calctype_mag); + update_specific(); } /**************************/ /* update calculationType */ @@ -542,6 +726,7 @@ void _update_calculationType(){ default: GUI_COMBOBOX_SET(uspex_gui.calculationType,0); } + update_specific(); } /************************/ /* update _calctype_dim */ @@ -1544,6 +1729,7 @@ void uspex_meta_model_selected(GUI_OBJ *w){ void update_vcnebType(void){ gchar *text; gint type=uspex_gui.calc._vcnebtype_method*100; + if(uspex_gui.calc.calculationMethod!=US_CM_VCNEB) return; if(uspex_gui.calc._vcnebtype_img_num) type+=10; if(uspex_gui.calc._vcnebtype_spring) type+=1; uspex_gui.calc.vcnebType=type; @@ -1758,17 +1944,12 @@ void load_substrate_model_file(void){ - - - - - /************************/ /* Switch notebook page */ /************************/ void uspex_gui_page_switch(GUI_NOTE *notebook,GUI_OBJ *page,guint page_num){ gint from_page; -// gchar *text; + gint idx; /* some (few) values need to be updated from a page to another*/ GUI_NOTE_PAGE_NUMBER(notebook,from_page); if(from_page==(gint)page_num) return;/*not moved*/ @@ -1793,10 +1974,14 @@ void uspex_gui_page_switch(GUI_NOTE *notebook,GUI_OBJ *page,guint page_num){ } else if (page_num==USPEX_PAGE_ADVANCED){ /**/ } else if (page_num==USPEX_PAGE_SPECIFIC){ - /**/ + /*update meta_model_button*/ + GUI_COMBOBOX_GET(uspex_gui.meta_model,idx); + if((uspex_gui.calc.calculationMethod==US_CM_META)&&(idx==0)) GUI_UNLOCK(uspex_gui.meta_model_button); + else GUI_LOCK(uspex_gui.meta_model_button); + /*update vcneb*/ + update_vcnebType(); } GUI_UNLOCK(page); - /*to be continued...*/ } /****************************************************/ /* convert current uspex_gui into uspex_calc_struct */ @@ -2128,19 +2313,6 @@ GUI_TOOLTIP(button,"checkMolecules: Ch. 4.1 DEFAULT: TRUE\nCheck and discard bro GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckCon",3,4,8,9);/*not calling anything*/ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardness and add connectivity in softmutation."); /* <- Ext Pressure, LDA+U, and magRation moved to p. III, II, and III, respectively.*/ -/* initialize */ - GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); - GUI_COMBOBOX_SETUP(uspex_gui.calculationType,0,uspex_type_selected); - GUI_COMBOBOX_SETUP(uspex_gui.optType,0,uspex_optimization_selected); - GUI_LOCK(uspex_gui._atom_typ); - populate_atomType(); - GUI_COMBOBOX_SETUP(uspex_gui.atomType,uspex_gui.calc._nspecies,atomType_selected); - GUI_SPIN_SET(uspex_gui._calctype_dim,(gdouble) uspex_gui.calc._calctype_dim); - mol_toggle(); - var_toggle(); - GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,goodBonds_selected); - auto_bond_toggle(); - opt_toggle(); /* --- cell */ GUI_LABEL_TABLE(table,"Cell",0,4,9,10); /* line 10 */ @@ -2190,13 +2362,6 @@ GUI_TOOLTIP(uspex_gui._centers,"Associate each molecule with a GDIS model."); /*col 4: empty*/ /* line 17: empty */ GUI_LABEL_TABLE(table," ",0,4,17,18); -/* initialize */ - GUI_COMBOBOX_SETUP(uspex_gui.IonDistances,0,uspex_IonDistances_selected); - GUI_COMBOBOX_SETUP(uspex_gui.MolCenters,0,uspex_MolCenters_selected); - refresh_constraints(); - toggle_auto_C_ion(); - GUI_COMBOBOX_SETUP(uspex_gui._latticeformat,1,uspex_latticeformat_selected); - uspex_latticeformat_selected(uspex_gui._latticeformat); /* --- end page */ /*---------------------*/ @@ -2305,8 +2470,6 @@ GUI_TOOLTIP(uspex_gui.antiSeedsSigma,"antiSeedsSigma: Ch. 4.10 DEFAULT: 0.001\nG GUI_TOOLTIP(uspex_gui.doSpaceGroup,"doSpaceGroup: Ch. 4.11 DEFAULT: TRUE\nActivate space group determination."); GUI_ENTRY_TABLE(table,uspex_gui.SymTolerance,uspex_gui.calc.SymTolerance,"%.4f","TOL:",3,4,14,15); GUI_TOOLTIP(uspex_gui.SymTolerance,"SymTolerance: Ch. 4.11 DEFAULT: 0.10\nPrecision for symmetry determination."); -/* initialize */ - SG_toggle(); /* --- Variable-composition */ GUI_LABEL_TABLE(table,"Variable-composition",0,4,15,16); /* line 16 */ @@ -2324,9 +2487,7 @@ GUI_TOOLTIP(uspex_gui.fracTrans,"fracTrans: Ch. 5.5 DEFAULT: 0.1\nFraction of st GUI_TOOLTIP(uspex_gui.howManyTrans,"howManyTrans: Ch. 5.5 DEFAULT: 0.2\nMaximum ratio of transmutated atoms in a structure."); GUI_TEXT_TABLE(table,uspex_gui.specificTrans,uspex_gui._tmp_specificTrans,"Trans: ",2,4,17,18); GUI_TOOLTIP(uspex_gui.specificTrans,"specificTrans: Ch. 5.5 DEFAULT: blank\nList of allowed transmutation."); -/* initialize */ - mag_toggle(); - +/* --- end page */ /*-----------------------*/ /* page 3 -> CALCULATION */ @@ -2389,11 +2550,6 @@ GUI_TOOLTIP(uspex_gui.remoteFolder,"remoteFolder: Ch. 4.8 DEFAULT: none\nExecuti for(idx=5;idx<18;idx++) GUI_LABEL_TABLE(table," ",0,4,idx,idx+1); - - - - - /* --- end page */ /*--------------------*/ @@ -2443,7 +2599,6 @@ GUI_TOOLTIP(uspex_gui.softMutOnly,"softMutOnly: Ch. ?.? DEFAULT: 0\nWhich/how ma GUI_TOOLTIP(uspex_gui.maxDistHeredity,"maxDistHeredity: Ch. 4.13 DEFAULT: 0.5\nMax fingerprint distance between structures chosen for heredity."); GUI_ENTRY_TABLE(table,uspex_gui.numberparents,uspex_gui.calc.numberparents,"%i","NumP:",1,2,6,7); GUI_TOOLTIP(uspex_gui.numberparents,"numberparents: Ch. 4.13 DEFAULT: 2\nNumber of parents chosen for heredity\nfor cluster calculation."); - GUI_COMBOBOX_TABLE(table,uspex_gui.manyParents,"many_P:",2,4,6,7); GUI_COMBOBOX_ADD(uspex_gui.manyParents,"0 - 2 parents, 1 slice each"); GUI_COMBOBOX_ADD(uspex_gui.manyParents,"1 - n structures, 1 slice each"); @@ -2500,41 +2655,37 @@ GUI_TOOLTIP(uspex_gui.magnitudeShoot_failure,"magnitudeShoot: Ch. 6.2 DEFAULT: 1 /* line 14 */ GUI_TEXT_TABLE(table,uspex_gui.cmdOrderParameter,uspex_gui.calc.cmdOrderParameter,"cmdOP:",0,2,14,15); GUI_TOOLTIP(uspex_gui.cmdOrderParameter,"cmdOrderParameter: Ch. 6.2 DEFAULT: none\nUser-defined command for order parameter calculation."); - GUI_OPEN_BUTTON_TABLE(table,button,load_cmd_OP,2,3,14,15); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.cmdOrderParameter_button,load_cmd_OP,2,3,14,15); GUI_ENTRY_TABLE(table,uspex_gui.opCriteria_start,uspex_gui.calc.opCriteria[0],"%.4f","SIM(start):",3,4,14,15); GUI_TOOLTIP(uspex_gui.opCriteria_start,"opCriteria: Ch. 6.2 DEFAULT: none\nAllowable degree of similarity between starting states."); /* line 15 */ GUI_TEXT_TABLE(table,uspex_gui.cmdEnthalpyTemperature,uspex_gui.calc.cmdEnthalpyTemperature,"cmdET:",0,2,15,16); -GUI_TOOLTIP(uspex_gui.cmdEnthalpyTemperature,"cmdEnthalpyTemperature: Ch. 6.2 DEFAULT: Y\nUser-defined command for enthalpy/temperature\nextraction from the MD results."); - GUI_OPEN_BUTTON_TABLE(table,button,load_cmd_ET,2,3,15,16); +GUI_TOOLTIP(uspex_gui.cmdEnthalpyTemperature,"cmdEnthalpyTemperature: Ch. 6.2 DEFAULT: none\nUser-defined command for enthalpy/temperature\nextraction from the MD results."); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.cmdEnthalpyTemperature_button,load_cmd_ET,2,3,15,16); GUI_ENTRY_TABLE(table,uspex_gui.opCriteria_end,uspex_gui.calc.opCriteria[1],"%.4f","SIM(end):",3,4,15,16); GUI_TOOLTIP(uspex_gui.opCriteria_end,"opCriteria: Ch. 6.2 DEFAULT: none\nAllowable degree of similarity between ending states."); /* line 16 */ GUI_TEXT_TABLE(table,uspex_gui.orderParameterFile,uspex_gui.calc.orderParameterFile,"OP_file:",0,1,16,17); GUI_TOOLTIP(uspex_gui.orderParameterFile,"orderParameterFile: Ch. 6.2 DEFAULT: fp.dat\nOrder parameter history file."); - GUI_OPEN_BUTTON_TABLE(table,button,load_OP_file,1,2,16,17); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.orderParameterFile_button,load_OP_file,1,2,16,17); GUI_TEXT_TABLE(table,uspex_gui.enthalpyTemperatureFile,uspex_gui.calc.enthalpyTemperatureFile,"ET_file:",2,3,16,17); GUI_TOOLTIP(uspex_gui.enthalpyTemperatureFile,"enthalpyTemperatureFile: Ch. 6.2 DEFAULT: HT.dat\nEnthalpy and temperature history file."); - GUI_OPEN_BUTTON_TABLE(table,button,load_ET_file,3,4,16,17); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.enthalpyTemperatureFile_button,load_ET_file,3,4,16,17); /* line 17 */ GUI_TEXT_TABLE(table,uspex_gui.trajectoryFile,uspex_gui.calc.trajectoryFile,"traj_file:",0,1,17,18); GUI_TOOLTIP(uspex_gui.trajectoryFile,"trajectoryFile: Ch. 6.2 DEFAULT: traj.dat\nMD trajectory file."); - GUI_OPEN_BUTTON_TABLE(table,button,load_traj_file,1,2,17,18); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.trajectoryFile_button,load_traj_file,1,2,17,18); GUI_TEXT_TABLE(table,uspex_gui.MDrestartFile,uspex_gui.calc.MDrestartFile,"MD_file:",2,3,17,18); GUI_TOOLTIP(uspex_gui.MDrestartFile,"MDrestartFile: Ch. 6.2 DEFAULT: traj.restart\nMD restart file."); - GUI_OPEN_BUTTON_TABLE(table,button,load_MDrestart_file,3,4,17,18); -/* initialize */ - GUI_COMBOBOX_SETUP(uspex_gui.dynamicalBestHM,2,uspex_dyn_HM_selected); - GUI_COMBOBOX_SETUP(uspex_gui.manyParents,0,uspex_manyParents_selected); - GUI_COMBOBOX_SETUP(uspex_gui.TE_goal,0,uspex_TE_goal_selected); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.MDrestartFile_button,load_MDrestart_file,3,4,17,18); /* --- end page */ /*--------------------*/ /* page 5 -> SPECIFIC */ /*--------------------*/ - GUI_PAGE_NOTE(notebook,page,"SPECIFIC"); + GUI_PAGE_NOTE(notebook,uspex_gui.specific_page,"SPECIFIC"); /* create a table in the page*/ - GUI_TABLE_NOTE(page,table,18,4); + GUI_TABLE_NOTE(uspex_gui.specific_page,table,18,4); /* --- Metadynamics */ GUI_LABEL_TABLE(table,"Metadynamics",0,4,0,1); /* line 1 */ @@ -2584,16 +2735,16 @@ GUI_TOOLTIP(uspex_gui._vcnebtype_spring,"Set whether spring constants should be /* line 7 */ GUI_ENTRY_TABLE(table,uspex_gui.numImages,uspex_gui.calc.numImages,"%i","N_Img:",0,1,7,8); GUI_TOOLTIP(uspex_gui.numImages,"numImages: Ch. 6.1 DEFAULT: 9\nInitial number of images."); - GUI_COMBOBOX_TABLE(table,uspex_gui.optReadImages,"Read_Img:",1,2,7,8); + GUI_COMBOBOX_TABLE(table,uspex_gui.optReadImages,"Img:",1,2,7,8); GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"0 - All structures are needed"); GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"1 - Only initial and final"); GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"2 - Initial and final + intermediates"); GUI_TOOLTIP(uspex_gui.optReadImages,"optReadImages: Ch. 6.1 DEFAULT: 2\nSet the method for reading Images file."); - GUI_COMBOBOX_TABLE(table,uspex_gui.optimizerType,"Opt_Type:",2,3,7,8); + GUI_COMBOBOX_TABLE(table,uspex_gui.optimizerType,"Opt:",2,3,7,8); GUI_COMBOBOX_ADD(uspex_gui.optimizerType,"1 - Steepest Descent"); GUI_COMBOBOX_ADD(uspex_gui.optimizerType,"2 - Fast Inertial Relaxation Engine"); GUI_TOOLTIP(uspex_gui.optimizerType,"optimizerType: Ch. 6.1 DEFAULT: 1\nSelect the optimization algorithm (SD or FIRE)."); - GUI_COMBOBOX_TABLE(table,uspex_gui.optRelaxType,"RelaxType:",3,4,7,8); + GUI_COMBOBOX_TABLE(table,uspex_gui.optRelaxType,"Relax:",3,4,7,8); GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"1 - fixed cell, positions relaxed (=NEB)"); GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"2 - cell lattice only (only for testing)"); GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"3 - full, cell and positions relaxation."); @@ -2670,7 +2821,33 @@ GUI_TOOLTIP(uspex_gui.reconstruct,"reconstruct: Ch. 5.3 DEFAULT: 1\nNumber of re GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (Ang.) of the buffer region."); /* line 17: empty*/ GUI_LABEL_TABLE(table," ",0,4,17,18); -/* initialize */ +/* --- end page */ + +/* initialize everything */ + GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); + GUI_COMBOBOX_SETUP(uspex_gui.calculationType,0,uspex_type_selected); + GUI_COMBOBOX_SETUP(uspex_gui.optType,0,uspex_optimization_selected); + GUI_LOCK(uspex_gui._atom_typ); + populate_atomType(); + GUI_COMBOBOX_SETUP(uspex_gui.atomType,uspex_gui.calc._nspecies,atomType_selected); + GUI_SPIN_SET(uspex_gui._calctype_dim,(gdouble) uspex_gui.calc._calctype_dim); + mol_toggle(); + var_toggle(); + GUI_COMBOBOX_SETUP(uspex_gui.goodBonds,0,goodBonds_selected); + auto_bond_toggle(); + opt_toggle(); + uspex_method_selected(uspex_gui.calculationMethod); + GUI_COMBOBOX_SETUP(uspex_gui.IonDistances,0,uspex_IonDistances_selected); + GUI_COMBOBOX_SETUP(uspex_gui.MolCenters,0,uspex_MolCenters_selected); + refresh_constraints(); + toggle_auto_C_ion(); + GUI_COMBOBOX_SETUP(uspex_gui._latticeformat,1,uspex_latticeformat_selected); + uspex_latticeformat_selected(uspex_gui._latticeformat); + SG_toggle(); + mag_toggle(); + GUI_COMBOBOX_SETUP(uspex_gui.dynamicalBestHM,2,uspex_dyn_HM_selected); + GUI_COMBOBOX_SETUP(uspex_gui.manyParents,0,uspex_manyParents_selected); + GUI_COMBOBOX_SETUP(uspex_gui.TE_goal,0,uspex_TE_goal_selected); GUI_COMBOBOX_SETUP(uspex_gui.FullRelax,2,uspex_relax_selected); GUI_COMBOBOX_SETUP(uspex_gui.meta_model,0,uspex_meta_model_selected); GUI_COMBOBOX_SETUP(uspex_gui._vcnebtype_method,0,uspex_vcneb_method_selected); @@ -2684,10 +2861,6 @@ GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (A update_vcnebType(); GUI_COMBOBOX_SETUP(uspex_gui.mol_model,0,uspex_mol_model_selected); GUI_COMBOBOX_SETUP(uspex_gui.substrate_model,0,uspex_substrate_model_selected); -/* --- end page */ - - - /* --- Outside of notebook */ GUI_FRAME_WINDOW(uspex_gui.window,frame); @@ -2701,6 +2874,7 @@ GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (A /* all done */ uspex_gui_refresh();/*refresh once more*/ GUI_SHOW(uspex_gui.window);/*display*/ + update_specific(); sysenv.refresh_dialog=TRUE; } diff --git a/src/gui_uspex.h b/src/gui_uspex.h index ffcd812..cc98a1f 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -44,12 +44,13 @@ struct uspex_calc_gui{ GUI_OBJ *window; /*connection to calculation parameters*/ uspex_calc_struct calc; - /*actual GUI*/ +/*actual GUI*/ gint cur_page; gboolean is_dirty; GUI_OBJ *name; GUI_OBJ *file_entry; gboolean have_output; + GUI_OBJ *specific_page;/*because this page can be locked if nothing relevant*/ /*4.1 Type of run & System*/ GUI_OBJ *calculationMethod; GUI_OBJ *calculationType; @@ -79,7 +80,6 @@ struct uspex_calc_gui{ GUI_OBJ *_bond_d; gchar *_tmp_bond_d; gboolean auto_bonds; - /**/ //checkMolecules is auto-sync //checkConnectivity is auto-sync GUI_OBJ *fitLimit; /*VER 10.1*/ @@ -119,13 +119,11 @@ struct uspex_calc_gui{ GUI_OBJ *IonDistances; GUI_OBJ *_distances; gchar *_tmp_distances; -// GUI_OBJ *curr_distance; gint _curr_distance; GUI_OBJ *minVectorLength; GUI_OBJ *MolCenters; GUI_OBJ *_centers; gchar *_tmp_centers; -// GUI_OBJ *curr_center; gint _curr_center; GUI_OBJ *constraint_enhancement; gboolean auto_C_ion; @@ -158,10 +156,6 @@ struct uspex_calc_gui{ GUI_OBJ *whichCluster; GUI_OBJ *remoteFolder; //PhaseDiagram is auto-sync - - - - /*4.9 fingerprint*/ GUI_OBJ *RmaxFing; GUI_OBJ *deltaFing; @@ -177,10 +171,10 @@ struct uspex_calc_gui{ GUI_OBJ *repeatForStatistics; GUI_OBJ *stopFitness; GUI_OBJ *fixRndSeed; -// GUI_OBJ *collectForces; + //collectForces is auto-sync /*4.13 seldom used*/ -// GUI_OBJ *ordering_active; -// GUI_OBJ *symmetrize; + //ordering_active is auto-sync + //symmetrize is auto-sync gchar *_tmp_valence_e; GUI_OBJ *valenceElectr; GUI_OBJ *percSliceShift; @@ -191,7 +185,6 @@ struct uspex_calc_gui{ GUI_OBJ *minSlice; GUI_OBJ *maxSlice; GUI_OBJ *numberparents; - /*5.1 molecular*/ GUI_OBJ *mol_model;/*additional*/ GUI_OBJ *mol_model_button;/*additional*/ @@ -273,12 +266,17 @@ struct uspex_calc_gui{ GUI_OBJ *opCriteria_start; GUI_OBJ *opCriteria_end; GUI_OBJ *cmdOrderParameter; + GUI_OBJ *cmdOrderParameter_button; GUI_OBJ *cmdEnthalpyTemperature; + GUI_OBJ *cmdEnthalpyTemperature_button; GUI_OBJ *orderParameterFile; + GUI_OBJ *orderParameterFile_button; GUI_OBJ *enthalpyTemperatureFile; + GUI_OBJ *enthalpyTemperatureFile_button; GUI_OBJ *trajectoryFile; + GUI_OBJ *trajectoryFile_button; GUI_OBJ *MDrestartFile; - + GUI_OBJ *MDrestartFile_button; /* CALCUL */ GUI_OBJ *job_uspex_exe; GUI_OBJ *job_path; From 3fa61a92e515ce7311313c9ae9e8fc1b537115f7 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Sat, 10 Nov 2018 14:51:27 +0900 Subject: [PATCH 42/56] file_uspex: fix incorrect reading of natoms with VER 10.1 --- src/file_uspex.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 45a96e2..506f03a 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -2304,7 +2304,7 @@ gint read_output_uspex(gchar *filename, struct model_pak *model){ /* results */ FILE *f_src; FILE *f_dest; - gint natoms; + gint natoms=0; gchar *atoms; uspex_output_struct *uspex_output; uspex_calc_struct *uspex_calc; @@ -3224,6 +3224,20 @@ else{ g_free(line); line = file_read_line(vf); } + /*get the total number of atoms*/ + rewind(vf); + for(idx=0;idx<6;idx++){ + line = file_read_line(vf); + g_free(line); + } + natoms=1;/*there is at least one atom*/ + ptr=&(line[0]); + do{ + natoms+=(gint)g_ascii_strtod(ptr,&ptr2); + if(ptr2==ptr) break; + ptr=ptr2; + }while(1); + /*all done*/ fclose(vf); } /* --- read energies from the Energy file */ From 3b95d3f2be79e73aebbdc49fa4a4d9ea69f4c1fa Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 12 Nov 2018 12:04:57 +0900 Subject: [PATCH 43/56] file_uspex: when relaxed information is present, data about unrelaxed individulals is now also displayed. --- src/file_uspex.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 506f03a..09a2f3c 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -2491,7 +2491,6 @@ if((_UC.calculationMethod==US_CM_USPEX) g_free(line); line = file_read_line(vf); } -// atom_per_supercell=0; ptr=&(line[0]); atom_n=g_malloc(_UO.calc->_nspecies*sizeof(gint)); natoms=0; @@ -2501,7 +2500,6 @@ if((_UC.calculationMethod==US_CM_USPEX) /*we also need a ratio for supercell calculations*/ atom_n[jdx]=(gint)g_ascii_strtoull(ptr,&ptr2,10); natoms+=atom_n[jdx]; -// atom_per_supercell+=; ptr=ptr2+1; jdx++; } @@ -2574,13 +2572,10 @@ if((_UC.calculationMethod==US_CM_USPEX) } /*exept for META, _UO.ind[0] will contain no data!*/ /* +++ load Individuals*/ - if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) - aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); - else aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); +/* ^^^ NEW: everyone reads Individuals first, then Individuals_relaxed (if exists)*/ + aux_file = g_strdup_printf("%s%s",res_folder,"Individuals"); if(read_individuals_uspex(aux_file,model)!=0) { - if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) - line = g_strdup_printf("ERROR: reading USPEX Individuals_relaxed file!\n"); - else line = g_strdup_printf("ERROR: reading USPEX Individuals file!\n"); + line = g_strdup_printf("ERROR: reading USPEX Individuals_relaxed file!\n"); gui_text_show(ERROR, line); g_free(line); g_free(aux_file); @@ -2590,11 +2585,21 @@ if((_UC.calculationMethod==US_CM_USPEX) if(_UO.have_supercell){ /*rescale atoms,natoms in case of a supercell calculation NOTE: first supercell has to be [1,1,1]*/ for(idx=0;idx<_UO.num_struct;idx++) { - for(jdx=0;jdx<_UO.calc->_nspecies;jdx++) _UO.ind[idx].atoms[jdx]=atom_n[jdx]*_UO.ind[idx].natoms; - _UO.ind[idx].natoms*=natoms; + for(jdx=0;jdx<_UO.calc->_nspecies;jdx++) _UO.ind[idx].atoms[jdx]=atom_n[jdx]*_UO.ind[idx].natoms; + _UO.ind[idx].natoms*=natoms; } } g_free(atom_n); + aux_file = g_strdup_printf("%s%s",res_folder,"Individuals_relaxed"); + if(read_individuals_uspex(aux_file,model)!=0) { + /*failure to load Individuals_relaxed is not an error, thus not fatal*/ + if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)){ + line = g_strdup_printf("WARNING: error reading USPEX Individuals_relaxed file!\n"); + gui_text_show(WARNING, line); + g_free(line); + } + } + g_free(aux_file); n_data=0;for(idx=0;idx<_UO.num_struct;idx++) if(_UO.ind[idx].have_data) n_data++; /* +++ get gatherPOSCARS information for have_data=FALSE (is any)*/ if((_UC.calculationMethod==US_CM_META)||(_UC.calculationMethod==US_CM_MINHOP)) From a3caec9f50213e08598d96ac3fe32051e6303085 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Mon, 12 Nov 2018 19:48:29 +0900 Subject: [PATCH 44/56] gui_uspex: uspex parameters VI VER 10.1 --- src/file_uspex.c | 67 ++++++++++++++++----- src/file_uspex.h | 4 +- src/gui_defs.h | 7 +++ src/gui_setup.c | 27 +++++---- src/gui_uspex.c | 147 +++++++++++++++++++++++++++++++++++++---------- src/gui_uspex.h | 16 +++++- src/main.c | 7 +++ src/pak.h | 3 + 8 files changed, 222 insertions(+), 56 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 09a2f3c..edbd4ca 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -124,6 +124,9 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.MolCenters=NULL; _UC.Latticevalues=NULL; _UC.splitInto=NULL; + _UC.pickUpYN=FALSE; + _UC.pickUpGen=0; + _UC.pickUpFolder=0; _UC._num_opt_steps=0; _UC.abinitioCode=NULL; _UC.KresolStart=NULL; @@ -424,7 +427,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); _UC.calculationType=1000; ptr++; } - i=g_ascii_digit_value(*ptr);/*dimension*/ + i=j*g_ascii_digit_value(*ptr);/*dimension*/ if((i!=-2)&&((i<0)||(i>3))) { g_free(line); line = file_read_line(vf); @@ -447,7 +450,7 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); continue; } _UC._calctype_var=(i==1); - _UC.calculationType+=(_UC._calctype_dim*100)+(_UC._calctype_mol*10)+_UC._calctype_var; + _UC.calculationType+=(j*_UC._calctype_dim*100)+(_UC._calctype_mol*10)+_UC._calctype_var; _UC.calculationType*=j; g_free(line); line = file_read_line(vf); @@ -991,6 +994,14 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); line = file_read_line(vf); continue; } + if (find_in_string("pickUpYN",line) != NULL) {/*pickUpYN is deprecated BTW*/ + sscanf(line,"%i%*s",&(i)); + _UC.pickUpYN=(i!=0); + g_free(line);line = file_read_line(vf); + continue; + } + __GET_INT(pickUpGen); + __GET_INT(pickUpFolder); if (find_in_string("abinitioCode",line) != NULL) { g_free(line);line = file_read_line(vf);/*go next line*/ /*look for abinitioCode*/ @@ -1490,6 +1501,7 @@ void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ _CP(constraint_enhancement); _CP(_nmolecules); _DBLCP(MolCenters,_SRC._nmolecules); + _CP(_nlatticevalues); if(_SRC._calctype_var){ _DBLCP(Latticevalues,_SRC._nlatticevalues); }else{ @@ -1497,7 +1509,11 @@ void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ else if(_SRC._nlatticevalues<=3) _DBLCP(Latticevalues,_SRC._nlatticevalues*_SRC._nlatticevalues); else if(_SRC._nlatticevalues==1) _DBLCP(Latticevalues,1); } + _CP(_nsplits); _COPY(splitInto,_SRC._nsplits,gint); + _CP(pickUpYN); + _CP(pickUpGen); + _CP(pickUpFolder); _CP(_num_opt_steps); _COPY(abinitioCode,_SRC._num_opt_steps,gint); _DBLCP(KresolStart,_SRC._num_opt_steps); @@ -1647,13 +1663,14 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ fprintf(vf,"%% %s\n",end_tag);\ is_w++;\ }while(0) -#define _CS(pre,tag,value) case pre##_##value: fprintf(vf,"%s\t :%s",__Q(value),__Q(tag));break +#define _CS(pre,tag,value) case pre##_##value: fprintf(vf,"%s\t :%s\n",__Q(value),__Q(tag));break /**/ FILE *vf,*dest; long int vfpos; gint is_w=0; gchar *line=NULL; - gint i,j;//,k; + gint i,j,k; + gboolean zero_check; /*tests*/ if(filename==NULL) return -1; if(uspex_calc==NULL) return -1; @@ -1714,8 +1731,10 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ return -3; } /*output resulting "Parameter.txt" input*/ - fprintf(vf,"PARAMETERS EVOLUTIONARY ALGORITHM\n"); - fprintf(vf,"GENERATED BY GDIS %4.2f.%d (C) %d\n",VERSION,PATCH,YEAR); + fprintf(vf,"* +++++++++++++++++++++++++++++++++ *\n"); + fprintf(vf,"* PARAMETERS EVOLUTIONARY ALGORITHM *\n"); + fprintf(vf,"* GENERATED BY GDIS %4.2f.%d (C) %d *\n",VERSION,PATCH,YEAR); + fprintf(vf,"* +++++++++++++++++++++++++++++++++ *\n"); if(_UC.name==NULL) _UC.name=g_strdup("(unnamed)"); line=g_strdup_printf("* CALCULATION: %s *",_UC.name); __TITLE(line); @@ -1751,14 +1770,14 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ _CS(US_CT,calculationType,s200); _CS(US_CT,calculationType,201); _CS(US_CT,calculationType,s201); - case US_CT_m200: fprintf(vf,"-200\t: calculationType");break; - case US_CT_sm200: fprintf(vf,"-s200\t: calculationType");break; + case US_CT_m200: fprintf(vf,"-200\t: calculationType\n");break; + case US_CT_sm200: fprintf(vf,"-s200\t: calculationType\n");break; default: fprintf(vf,"???\t: calculationType (unsupported type)\n"); } if(_UC.new_optType==NULL){ /*old fashion optType*/ - if(_UC.anti_opt) __OUT_INT(optType); + if(!_UC.anti_opt) __OUT_INT(optType); else { fprintf(vf,"%i\t: optType\n",-1*_UC.optType); } @@ -1792,7 +1811,9 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ if(_UC.calculationMethod==US_CM_META) __OUT_DOUBLE(ExternalPressure); if(_UC.ExternalPressure!=0.) __OUT_DOUBLE(ExternalPressure); /*print when NOT default or unset*/ - if(_UC.valences!=NULL) __OUT_BK_INT(valences,"endValences",_UC._nspecies); + /*do not print valences if all of them are zero*/ + zero_check=FALSE;for(i=0;i<_UC._nspecies;i++) zero_check|=(_UC.valences[i]!=0); + if(zero_check && (_UC.valences!=NULL)) __OUT_BK_INT(valences,"endValences",_UC._nspecies); if(_UC.goodBonds!=NULL) __OUT_TMAT_DOUBLE(goodBonds,"EndGoodBonds",_UC._nspecies);/*TODO: use of a single value is unsupported*/ if(!_UC.checkMolecules) __OUT_BOOL(checkMolecules); if(_UC.checkConnectivity) __OUT_BOOL(checkConnectivity); @@ -1813,7 +1834,9 @@ is_w=0; __TITLE(line); g_free(line); if(_UC.bestFrac!=0.7) __OUT_DOUBLE(bestFrac); - if(_UC.keepBestHM!=0) __OUT_INT(keepBestHM); + /*default keepBestHM*/ + i=(gint)(0.15*(_UC.populationSize)); + if((_UC.keepBestHM!=i)&&(_UC.keepBestHM!=0)) __OUT_INT(keepBestHM); if(_UC.reoptOld) __OUT_BOOL(reoptOld); if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ @@ -1839,7 +1862,12 @@ is_w=0; if(_UC.fracLatMut!=0.1) __OUT_DOUBLE(fracLatMut); } if(_UC.fracSpinMut!=0.1) __OUT_DOUBLE(fracSpinMut);/*VER 10.1*/ - if(_UC.howManySwaps!=0) __OUT_INT(howManySwaps); + /*default howManySwaps*/ + k=0; + for(i=0;i<(_UC._nspecies-1);i++) + for(j=i+1;j<_UC._nspecies;j++) k+=MIN(_UC.numSpecies[i],_UC.numSpecies[j]); + k*=0.5; + if((_UC.howManySwaps!=k) && (_UC.howManySwaps!=0)) __OUT_INT(howManySwaps); if(_UC.specificSwaps!=NULL) __OUT_BK_STRING(specificSwaps,"EndSpecific"); if(_UC.mutationDegree!=0.) __OUT_DOUBLE(mutationDegree); if(_UC.mutationRate!=0.5) __OUT_DOUBLE(mutationRate); @@ -1852,7 +1880,9 @@ is_w=0; __TITLE(line); g_free(line); if(_UC.minVectorLength!=0.) __OUT_DOUBLE(minVectorLength); - if(_UC.IonDistances!=NULL) __OUT_TMAT_DOUBLE(IonDistances,"EndDistances",_UC._nspecies); + /*do not print IonDistances if all of them are zero*/ + zero_check=FALSE;for(i=0;i<_UC._nspecies;i++) zero_check|=(_UC.IonDistances[i]!=0.0); + if(zero_check && (_UC.IonDistances!=NULL)) __OUT_TMAT_DOUBLE(IonDistances,"EndDistances",_UC._nspecies); if(!_UC.constraint_enhancement) __OUT_BOOL(constraint_enhancement); if(_UC.MolCenters!=NULL) __OUT_TMAT_DOUBLE(MolCenters,"EndMol",_UC._nmolecules); if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ @@ -1873,6 +1903,15 @@ is_w=0; if(_UC.splitInto!=NULL) __OUT_BK_INT(splitInto,"EndSplitInto",_UC._nsplits); if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ +is_w=0; + line=g_strdup_printf("* RESTART *"); + __TITLE(line); + g_free(line); + if(_UC.pickUpYN) __OUT_BOOL(pickUpYN); + if(_UC.pickUpGen!=0) __OUT_INT(pickUpGen); + if(_UC.pickUpFolder!=0) __OUT_INT(pickUpFolder); +if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ +else vfpos=ftell(vf);/* flag */ is_w=0; line=g_strdup_printf("* AB INITIO CALCULATION *"); __TITLE(line); @@ -2043,6 +2082,7 @@ is_w=0; line=g_strdup_printf("* TRANSITION PATH SAMPLING (TPS) *");/*VER 10.1*/ __TITLE(line); g_free(line); +if(_UC.calculationMethod==US_CM_TPS){/*because some values don't have default*/ if(_UC.numIterations!=1000) __OUT_INT(numIterations); if(_UC.speciesSymbol!=NULL) __OUT_BK_STRING(speciesSymbol,"EndSpeciesSymbol"); if(_UC.mass!=NULL) __OUT_BK_DOUBLE(mass,"endMass",_UC._nspecies); @@ -2057,6 +2097,7 @@ is_w=0; if(_UC.enthalpyTemperatureFile!=NULL) __OUT_STRING(enthalpyTemperatureFile); if(_UC.trajectoryFile!=NULL) __OUT_STRING(trajectoryFile); if(_UC.MDrestartFile!=NULL) __OUT_STRING(MDrestartFile); +} if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ line=g_strdup_printf("* END OF FILE *"); diff --git a/src/file_uspex.h b/src/file_uspex.h index 7fe2cc4..a4fe0ac 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -169,7 +169,9 @@ typedef struct { gint _nsplits; /*HIDDEN: number of splits*/ gint *splitInto; /*number of subcells into which unit cell is split*/ /*4.7 Restart*/ - /*Restart is unsupported*/ + gboolean pickUpYN; /*select whether to perform a restart (deprecated)*/ + gint pickUpGen; /*generation from which to restart from*/ + gint pickUpFolder; /*result forder index from which to restart from*/ /*4.8 Ab initio calculations*/ gint _num_opt_steps; /*HIDDEN: number of optimization steps*/ gint *abinitioCode; /*calculation code used for each optimization steps*/ diff --git a/src/gui_defs.h b/src/gui_defs.h index d5d7000..61bdcf4 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -313,6 +313,13 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_SPIN_SET(spin,value) do{\ gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin),value);\ }while(0) +/*Create a new cell with: + * a button (button) with label "text" connected on click to function (function)*/ +#define GUI_BUTTON_TABLE(table,button,text,function,l,r,t,b) do{\ + button=gtk_button_new_with_label (text);\ + _ATTACH_TABLE(table,button,l,r,t,b);\ + g_signal_connect(GTK_OBJECT(button),"clicked",GTK_SIGNAL_FUNC(function),NULL);\ +}while(0) /*Create a new cell with: * an open button (button) connected on click to function (function).*/ #define GUI_OPEN_BUTTON_TABLE(table,button,function,l,r,t,b) do{\ diff --git a/src/gui_setup.c b/src/gui_setup.c index 61d273f..c3f8b39 100644 --- a/src/gui_setup.c +++ b/src/gui_setup.c @@ -52,7 +52,7 @@ frame = gtk_frame_new(NULL); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(window)->vbox), frame, FALSE, FALSE, PANEL_SPACING); gtk_container_set_border_width(GTK_CONTAINER(frame), PANEL_SPACING); -table = gtk_table_new(2, 8, FALSE); +table = gtk_table_new(2, 9, FALSE); gtk_container_add(GTK_CONTAINER(frame), table); gtk_container_set_border_width(GTK_CONTAINER(table), PANEL_SPACING); @@ -77,39 +77,46 @@ vbox = gtk_vbox_new(TRUE, 0); gtk_table_attach_defaults(GTK_TABLE(table),vbox,1,2,2,3); gui_text_entry(NULL, &sysenv.vasp_path, TRUE, TRUE, vbox); -label = gtk_label_new("MPIRUN"); +label = gtk_label_new("USPEX"); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,3,4); vbox = gtk_vbox_new(TRUE, 0); gtk_table_attach_defaults(GTK_TABLE(table),vbox,1,2,3,4); -gui_text_entry(NULL, &sysenv.mpirun_path, TRUE, TRUE, vbox); +gui_text_entry(NULL, &sysenv.uspex_path, TRUE, TRUE, vbox); -label = gtk_label_new("GULP"); +label = gtk_label_new("MPIRUN"); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,4,5); vbox = gtk_vbox_new(TRUE, 0); gtk_table_attach_defaults(GTK_TABLE(table),vbox,1,2,4,5); -gui_text_entry(NULL, &sysenv.gulp_path, TRUE, TRUE, vbox); +gui_text_entry(NULL, &sysenv.mpirun_path, TRUE, TRUE, vbox); -label = gtk_label_new("Monty"); +label = gtk_label_new("GULP"); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,5,6); vbox = gtk_vbox_new(TRUE, 0); gtk_table_attach_defaults(GTK_TABLE(table),vbox,1,2,5,6); -gui_text_entry(NULL, &sysenv.monty_path, TRUE, TRUE, vbox); +gui_text_entry(NULL, &sysenv.gulp_path, TRUE, TRUE, vbox); -label = gtk_label_new("POVRay"); +label = gtk_label_new("Monty"); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,6,7); vbox = gtk_vbox_new(TRUE, 0); gtk_table_attach_defaults(GTK_TABLE(table),vbox,1,2,6,7); -gui_text_entry(NULL, &sysenv.povray_path, TRUE, TRUE, vbox); +gui_text_entry(NULL, &sysenv.monty_path, TRUE, TRUE, vbox); -label = gtk_label_new("Image viewer "); +label = gtk_label_new("POVRay"); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,7,8); vbox = gtk_vbox_new(TRUE, 0); gtk_table_attach_defaults(GTK_TABLE(table),vbox,1,2,7,8); +gui_text_entry(NULL, &sysenv.povray_path, TRUE, TRUE, vbox); + +label = gtk_label_new("Image viewer "); +gtk_misc_set_alignment(GTK_MISC(label), 0, 0); +gtk_table_attach_defaults(GTK_TABLE(table),label,0,1,8,9); +vbox = gtk_vbox_new(TRUE, 0); +gtk_table_attach_defaults(GTK_TABLE(table),vbox,1,2,8,9); gui_text_entry(NULL, &sysenv.viewer_path, TRUE, TRUE, vbox); /* termination */ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index bb8dab0..b3715b3 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -192,6 +192,8 @@ void gui_uspex_init(struct model_pak *model){ uspex_gui.calc.IonDistances = g_malloc(uspex_gui.calc._nspecies*uspex_gui.calc._nspecies*sizeof(gdouble)); for(idx=0;idx Date: Tue, 13 Nov 2018 20:02:37 +0900 Subject: [PATCH 45/56] gui_uspex: add variable composition cluster calculation + many fixes ; file_uspex: converge saving INPUT.txt with example cases + many fixes --- src/file_uspex.c | 114 +++++++++++++------- src/file_uspex.h | 1 + src/gui_uspex.c | 268 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 322 insertions(+), 61 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index edbd4ca..c61a4e5 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -96,7 +96,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.checkConnectivity=FALSE; _UC.fitLimit=0.; //VER 10.1 _UC.populationSize=0; - _UC.initialPopSize=0; + _UC.initialPopSize=-1;/*zero actually have a meaning*/ _UC.numGenerations=100; _UC.stopCrit=0; _UC.bestFrac=0.7; @@ -266,6 +266,7 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ gchar *ptr,*ptr2; gchar c; gint i,j,k; + guint n_size; uspex_calc_struct *uspex_calc; /*tests*/ if(filename==NULL) return NULL; @@ -694,16 +695,24 @@ fprintf(stdout,"#DBG: PROBE LINE: %s",line); _UC._var_nspecies++; }while(find_in_string("EndNumSpeci",line) == NULL); /*_BUG_ VER 10.1 EX26 has a consistent typo (EndNumSpecices instead of EndNumSpecies)*/ +/*_BUG_ when _cactype_mol=TRUE numSpecies actually refer to a number of molecules, and thus depends on _nmolecules*/ +if((_UC._calctype_mol)&&(_UC._nmolecules==0)){ + /*numSpecies refer to molecules, but _nmolecules has not been calculated.*/ + ptr=&(line[0]); + __COUNT_ALNUM(ptr,_UC._nmolecules); +} fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ g_free(line);/*FIX: _VALGRIND_BUG_*/ line = file_read_line(vf);/*first line of numSpecies*/ - _UC.numSpecies = g_malloc(_UC._nspecies*_UC._var_nspecies*sizeof(gint)); - for(i=0;i<_UC._nspecies*_UC._var_nspecies;i++) _UC.numSpecies[i]=0; +if(_UC._calctype_mol) n_size=_UC._nmolecules; +else n_size=_UC._nspecies; + _UC.numSpecies = g_malloc(n_size*_UC._var_nspecies*sizeof(gint)); + for(i=0;i1)&&(_UC.MolCenters==NULL)) { line = g_strdup_printf("ERROR: USPEX - molecular calculation but missing MolCenters!\n"); @@ -1707,18 +1720,18 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ gui_text_show(ERROR, line);g_free(line); return -5; } +/*this is not an error as per EX14, EX19, EX22*/ if((_UC._calctype_var)&&(_UC.minAt==0)){ - line = g_strdup_printf("ERROR: USPEX - varcomp calculation but missing minAt!\n"); - gui_text_show(ERROR, line);g_free(line); - return -5; + line = g_strdup_printf("WARNING: USPEX - varcomp calculation but missing minAt!\n"); + gui_text_show(WARNING, line);g_free(line); } +/*this is not an error as per EX19*/ if((_UC._calctype_var)&&(_UC.maxAt==0)){ - line = g_strdup_printf("ERROR: USPEX - varcomp calculation but missing maxAt!\n"); - gui_text_show(ERROR, line);g_free(line); - return -5; + line = g_strdup_printf("WARNING: USPEX - varcomp calculation but missing maxAt!\n"); + gui_text_show(WARNING, line);g_free(line); } - if((_UC.calculationMethod==US_CM_META)&&(_UC.maxVectorLength=0.)){ - line = g_strdup_printf("ERROR: USPEX - META calculation but missong maxVectorLength!\n"); + if((_UC.calculationMethod==US_CM_META)&&(_UC.maxVectorLength==0.)){ + line = g_strdup_printf("ERROR: USPEX - META calculation but missing maxVectorLength!\n"); gui_text_show(ERROR, line);g_free(line); return -5; } @@ -1739,7 +1752,7 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ line=g_strdup_printf("* CALCULATION: %s *",_UC.name); __TITLE(line); g_free(line); - line=g_strdup_printf("* TYPE OF RUN AND SYSTEM *"); + line=g_strdup_printf("* TYPE OF RUN AND SYSTEM *"); __TITLE(line); g_free(line); /*always print:*/ @@ -1755,6 +1768,7 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ default: fprintf(vf,"???\t: calculationMethod (unsupported method)\n"); } +if((_UC.calculationMethod != US_CM_VCNEB)&&(_UC.calculationMethod != US_CM_TPS)){ /*VER 10.1: new magnetic 's' prefix added*/ switch(_UC.calculationType){ _CS(US_CT,calculationType,300); @@ -1765,6 +1779,7 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ _CS(US_CT,calculationType,311); _CS(US_CT,calculationType,000); _CS(US_CT,calculationType,s000); + _CS(US_CT,calculationType,001); _CS(US_CT,calculationType,110); _CS(US_CT,calculationType,200); _CS(US_CT,calculationType,s200); @@ -1775,6 +1790,7 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ default: fprintf(vf,"???\t: calculationType (unsupported type)\n"); } +if(_UC.calculationMethod != US_CM_MINHOP){ if(_UC.new_optType==NULL){ /*old fashion optType*/ if(!_UC.anti_opt) __OUT_INT(optType); @@ -1785,18 +1801,35 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ /*VER 10.1: new optType*/ __OUT_BK_STRING(new_optType,"EndOptType"); } - __OUT_BK_INT(atomType,"EndAtomType",_UC._nspecies); +}/*MINHOP don't require optType*/ +}/*VCNEB,TPS don't require calculationType,optType*/ + /*NEW: use symbols*/ + fprintf(vf,"%% atomType\n"); + fprintf(vf,"%s",elements[_UC.atomType[0]].symbol);/*there is at least 1 atomType*/ + for(i=1;i<(_UC._nspecies);i++) fprintf(vf," %s",elements[_UC.atomType[i]].symbol); + fprintf(vf,"\n");fprintf(vf,"%% EndAtomType\n"); if(_UC._var_nspecies==1){ - __OUT_BK_INT(numSpecies,"EndNumSpecies",_UC._nspecies); + if(_UC._calctype_mol) __OUT_BK_INT(numSpecies,"EndNumSpecies",_UC._nmolecules); + else __OUT_BK_INT(numSpecies,"EndNumSpecies",_UC._nspecies); is_w++; }else{ + /*numSpecies can be set as a variable composition molecules block? - I think yes*/ fprintf(vf,"%% numSpecies\n"); +if(_UC._calctype_mol){ + for(i=0;i<_UC._var_nspecies;i++){ + for(j=0;j<_UC._nmolecules;j++){ + fprintf(vf,"%i ",_UC.numSpecies[j+i*_UC._nmolecules]); + } + fprintf(vf,"\n"); + } +}else{ for(i=0;i<_UC._var_nspecies;i++){ for(j=0;j<_UC._nspecies;j++){ fprintf(vf,"%i ",_UC.numSpecies[j+i*_UC._nspecies]); } fprintf(vf,"\n"); } +} fprintf(vf,"%% EndNumSpecies\n"); is_w++; } @@ -1809,7 +1842,7 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ __OUT_BK_DOUBLE(ldaU,"EndLdaU",_UC._nspecies); } if(_UC.calculationMethod==US_CM_META) __OUT_DOUBLE(ExternalPressure); - if(_UC.ExternalPressure!=0.) __OUT_DOUBLE(ExternalPressure); + else if(_UC.ExternalPressure!=0.) __OUT_DOUBLE(ExternalPressure); /*print when NOT default or unset*/ /*do not print valences if all of them are zero*/ zero_check=FALSE;for(i=0;i<_UC._nspecies;i++) zero_check|=(_UC.valences[i]!=0); @@ -1820,17 +1853,23 @@ gint dump_uspex_parameters(gchar *filename,uspex_calc_struct *uspex_calc){ if(_UC.fitLimit!=0.) __OUT_DOUBLE(fitLimit);/*VER 10.1*/ vfpos=ftell(vf);/* flag */ is_w=0; - line=g_strdup_printf("* POPULATION *"); + line=g_strdup_printf("* POPULATION *"); __TITLE(line); g_free(line); +if((_UC.calculationMethod != US_CM_VCNEB)&&(_UC.calculationMethod != US_CM_TPS)){ if(_UC.populationSize!=0) __OUT_INT(populationSize); - if((_UC.initialPopSize!=0)&&(_UC.initialPopSize!=_UC.populationSize)) __OUT_INT(initialPopSize); + if((_UC.initialPopSize>=0)&&(_UC.initialPopSize!=_UC.populationSize)) __OUT_INT(initialPopSize); if(_UC.numGenerations!=100) __OUT_INT(numGenerations); - if(_UC.stopCrit!=0) __OUT_INT(stopCrit); + /*default stopCrit*/ + if(_UC._calctype_var) i=_UC.maxAt; + else {/*given the number numSpecies meaning, this should be revised*/ + i=0;for(j=0;j<_UC._nspecies;j++) i+=_UC.numSpecies[j]; + } + if((_UC.stopCrit!=i)&&(_UC.stopCrit!=0)) __OUT_INT(stopCrit); if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; - line=g_strdup_printf("* SURVIVAL OF THE FITTEST & SELECTION *"); + line=g_strdup_printf("* SURVIVAL & SELECTION *"); __TITLE(line); g_free(line); if(_UC.bestFrac!=0.7) __OUT_DOUBLE(bestFrac); @@ -1841,7 +1880,7 @@ is_w=0; if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; - line=g_strdup_printf("* STRUCTURE GENERATION & VARIATION OPERATORS *"); + line=g_strdup_printf("* VARIATION OPERATORS *"); __TITLE(line); g_free(line); if(_UC.symmetries!=NULL) __OUT_BK_STRING(symmetries,"endSymmetries"); @@ -1873,6 +1912,7 @@ is_w=0; if(_UC.mutationRate!=0.5) __OUT_DOUBLE(mutationRate); if(_UC.DisplaceInLatmutation!=1.0) __OUT_DOUBLE(DisplaceInLatmutation); if(_UC.AutoFrac) __OUT_BOOL(AutoFrac); +}/*VCNEB,TPS don't require POPULATION, SURVIVAL & SELECTION, or VARIATION OPERATORS information*/ if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; @@ -1891,6 +1931,7 @@ is_w=0; line=g_strdup_printf("* CELL *"); __TITLE(line); g_free(line); +if((_UC.calculationMethod != US_CM_VCNEB)&&(_UC.calculationMethod != US_CM_TPS)){ if(_UC.Latticevalues!=NULL){ if(_UC._calctype_var) { /*should be 1 line*/ @@ -1901,6 +1942,7 @@ is_w=0; } } if(_UC.splitInto!=NULL) __OUT_BK_INT(splitInto,"EndSplitInto",_UC._nsplits); +}/*VCNEB,TPS don't require CELL information*/ if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; @@ -1913,14 +1955,15 @@ is_w=0; if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; - line=g_strdup_printf("* AB INITIO CALCULATION *"); + line=g_strdup_printf("* DETAILS OF AB INITIO CALCULATIONS *"); __TITLE(line); g_free(line); if(_UC.abinitioCode!=NULL) __OUT_BK_INT(abinitioCode,"ENDabinit",_UC._num_opt_steps); if(_UC.KresolStart!=NULL) __OUT_BK_DOUBLE(KresolStart,"Kresolend",_UC._num_opt_steps); if(_UC.vacuumSize!=NULL) __OUT_BK_DOUBLE(vacuumSize,"endVacuumSize",_UC._num_opt_steps); if(_UC.numParallelCalcs!=1) __OUT_INT(numParallelCalcs); - __OUT_BK_STRING(commandExecutable,"EndExecutable");/*mandatory block*/ +/*often commandExecutable (which should be mandatory) is omitted when abinitioCode==1 (VASP)*/ + if((_UC.abinitioCode[0]!=0)&&(_UC.commandExecutable!=NULL)) __OUT_BK_STRING(commandExecutable,"EndExecutable");/*let's be permissive*/ if(_UC.whichCluster!=0) __OUT_INT(whichCluster); if((_UC.whichCluster==2)&&(_UC.remoteFolder!=NULL)) __OUT_STRING(remoteFolder); if(_UC.PhaseDiagram) __OUT_BOOL(PhaseDiagram); @@ -1985,6 +2028,7 @@ is_w=0; line=g_strdup_printf("* BOLTZTRAP *");/*VER 10.1*/ __TITLE(line); g_free(line); +if((_UC.calculationMethod != US_CM_VCNEB)&&(_UC.calculationMethod != US_CM_TPS)){ if(_UC.BoltzTraP_T_max!=800.0) __OUT_DOUBLE(BoltzTraP_T_max); if(_UC.BoltzTraP_T_delta!=50.0) __OUT_DOUBLE(BoltzTraP_T_delta); if(_UC.BoltzTraP_T_efcut!=0.15) __OUT_DOUBLE(BoltzTraP_T_efcut); @@ -2025,10 +2069,9 @@ is_w=0; __TITLE(line); g_free(line); if(_UC.firstGeneMax!=11) __OUT_INT(firstGeneMax); - if(_UC._calctype_var){/*mandatory if varcomp*/ - __OUT_INT(minAt); - __OUT_INT(maxAt); - } + /*minAt and maxAt are authorized outside of variable composition*/ + if(_UC.minAt!=0) __OUT_INT(minAt); + if(_UC.maxAt!=0) __OUT_INT(maxAt); if(_UC.fracTrans!=0.1) __OUT_DOUBLE(fracTrans); if(_UC.howManyTrans!=0.2) __OUT_DOUBLE(howManyTrans); if(_UC.specificTrans!=NULL) __OUT_BK_INT(specificTrans,"EndTransSpecific",_UC._nspetrans); @@ -2051,6 +2094,7 @@ is_w=0; if(_UC.PSO_softMut!=1.) __OUT_DOUBLE(PSO_softMut); if(_UC.PSO_BestStruc!=1.) __OUT_DOUBLE(PSO_BestStruc); if(_UC.PSO_BestEver!=1.) __OUT_DOUBLE(PSO_BestEver); +}/*VCNEB,TPS don't require BOLTZTRAP, SURFACES, VARCOMP, METADYNAMICS, or PSO information*/ if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; diff --git a/src/file_uspex.h b/src/file_uspex.h index a4fe0ac..f8424e4 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -46,6 +46,7 @@ typedef enum{ US_CT_311=311, /*bulk crystals; mol; var*/ US_CT_000=0, /*nanoparticles; no-mol; no-var*/ US_CT_s000=1000, /*+magnetic VER 10.1*/ + US_CT_001=1, /*+cluster VER 10.1*/ US_CT_110=110, /*polymers; no-mol; no-var*/ US_CT_200=200, /*surfaces; no-mol; no-var*/ US_CT_s200=1200, /*+magnetic VER 10.1*/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index b3715b3..8d4eaf7 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -105,9 +105,12 @@ void gui_uspex_init(struct model_pak *model){ idx++; } } - if(uspex_gui.calc.valences!=NULL) g_free(uspex_gui.calc.valences); - uspex_gui.calc.valences = g_malloc(uspex_gui.calc._nspecies*sizeof(gint)); - for(idx=0;idx0){ + if((uspex_gui.calc._nmolecules>0)&&(uspex_gui.calc.MolCenters!=NULL)){ /*refresh MolCenters*/ GUI_UNLOCK(uspex_gui.MolCenters); GUI_UNLOCK(uspex_gui._centers); @@ -2276,6 +2491,7 @@ GUI_TOOLTIP(uspex_gui.calculationMethod,"calculationMethod: Ch. 4.1 DEFAULT: USP GUI_COMBOBOX_ADD(uspex_gui.calculationType,"311"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"000"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s000"); + GUI_COMBOBOX_ADD(uspex_gui.calculationType,"001"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"110"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"200"); GUI_COMBOBOX_ADD(uspex_gui.calculationType,"s200"); @@ -2455,8 +2671,8 @@ GUI_TOOLTIP(uspex_gui.mag_aflh,"magRatio: Ch. 4.1 DEFAULT: 0.1\n(magnetic calcul GUI_TOOLTIP(uspex_gui.bestFrac,"bestFrac: Ch. 4.3 DEFAULT: 0.7\nFraction of current generation used to generate the next."); GUI_ENTRY_TABLE(table,uspex_gui.keepBestHM,uspex_gui.calc.keepBestHM,"%3i","BestHM:",1,2,4,5); GUI_TOOLTIP(uspex_gui.keepBestHM,"keepBestHM: Ch. 4.3 DEFAULT: auto\nNumber of best structures that will survive in next generation."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.reoptOld,NULL,"reopt",2,3,4,5);/*not calling anything*/ -GUI_TOOLTIP(button,"reoptOld: Ch. 4.3 DEFAULT: FALSE\nIf set surviving structure will be re-optimized."); + GUI_CHECK_TABLE(table,uspex_gui.reoptOld,uspex_gui.calc.reoptOld,NULL,"reopt",2,3,4,5);/*not calling anything*/ +GUI_TOOLTIP(uspex_gui.reoptOld,"reoptOld: Ch. 4.3 DEFAULT: FALSE\nIf set surviving structure will be re-optimized."); GUI_ENTRY_TABLE(table,uspex_gui.fitLimit,uspex_gui.calc.fitLimit,"%.4f","BestFIT:",3,4,4,5); GUI_TOOLTIP(uspex_gui.fitLimit,"fitLimit: Ch. 4.3 DEFAULT: none\nStop calculation when fitLimit fitness is reached."); /* --- Structure & Variation */ @@ -2906,9 +3122,9 @@ GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (A /* --- end page */ /* initialize everything */ - GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,0,uspex_method_selected); - GUI_COMBOBOX_SETUP(uspex_gui.calculationType,0,uspex_type_selected); - GUI_COMBOBOX_SETUP(uspex_gui.optType,0,uspex_optimization_selected); + GUI_COMBOBOX_SETUP(uspex_gui.calculationMethod,uspex_gui.calc.calculationMethod,uspex_method_selected); + GUI_COMBOBOX_SETUP(uspex_gui.calculationType,uspex_gui.calc.calculationType,uspex_type_selected); + GUI_COMBOBOX_SETUP(uspex_gui.optType,uspex_gui.calc.optType,uspex_optimization_selected); GUI_LOCK(uspex_gui._atom_typ); populate_atomType(); GUI_COMBOBOX_SETUP(uspex_gui.atomType,uspex_gui.calc._nspecies,atomType_selected); From 6ad7c36a4773bf35061b6924f5a53ebdee916b6f Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 14 Nov 2018 11:28:25 +0900 Subject: [PATCH 46/56] file_uspex: deal with parenthesis for jobs mixing fixed and full relaxation. --- src/file_uspex.c | 41 ++++++++++++++++++++++++++++++++++++++++- src/file_uspex.h | 1 + 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index c61a4e5..5823e29 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -129,6 +129,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.pickUpFolder=0; _UC._num_opt_steps=0; _UC.abinitioCode=NULL; + _UC._isfixed=NULL; _UC.KresolStart=NULL; _UC.vacuumSize=NULL; _UC.numParallelCalcs=1; @@ -238,6 +239,7 @@ void free_uspex_parameters(uspex_calc_struct *uspex_calc){ g_free(_UC.Latticevalues); g_free(_UC.splitInto); g_free(_UC.abinitioCode); + g_free(_UC._isfixed); g_free(_UC.KresolStart); g_free(_UC.vacuumSize); g_free(_UC.commandExecutable); @@ -1018,12 +1020,30 @@ else n_size=_UC._nspecies; for(i=0;i<_UC._num_opt_steps;i++) _UC.abinitioCode[i]=0; ptr=&(line[0]);i=0; /*TODO: deal with META parenthesis here!*/ +_UC._isfixed = g_malloc(_UC._num_opt_steps*sizeof(gboolean)); +for(i=0;i<_UC._num_opt_steps;i++) _UC._isfixed[i]=TRUE; +i=0;n_size=0; +while((*ptr!='\n')&&(*ptr!='\0')){ + __SKIP_BLANK(ptr); + if(*ptr=='(') { + n_size=1; + ptr++; + } + if(n_size==0) _UC._isfixed[i]=TRUE; + else _UC._isfixed[i]=FALSE; + _UC.abinitioCode[i]=(gint)g_ascii_strtoull(ptr,&ptr2,10); + if(*ptr2==')') n_size=0; + ptr=ptr2+1; + i++; +} +/* while((*ptr!='\n')&&(*ptr!='\0')){ __SKIP_BLANK(ptr); _UC.abinitioCode[i]=(gint)g_ascii_strtoull(ptr,&ptr2,10); ptr=ptr2+1; i++; } +*/ g_free(line); line = file_read_line(vf);/*this is the ENDabinit line*/ g_free(line); @@ -1526,6 +1546,7 @@ void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ _CP(pickUpFolder); _CP(_num_opt_steps); _COPY(abinitioCode,_SRC._num_opt_steps,gint); + _COPY(_isfixed,_SRC._num_opt_steps,gboolean); _DBLCP(KresolStart,_SRC._num_opt_steps); _DBLCP(vacuumSize,_SRC._num_opt_steps); _CP(numParallelCalcs); @@ -1958,7 +1979,25 @@ is_w=0; line=g_strdup_printf("* DETAILS OF AB INITIO CALCULATIONS *"); __TITLE(line); g_free(line); - if(_UC.abinitioCode!=NULL) __OUT_BK_INT(abinitioCode,"ENDabinit",_UC._num_opt_steps); + if(_UC.abinitioCode!=NULL) { +/*NEW: deals with parenthesis*/ + fprintf(vf,"%% abinitioCode\n"); + if(!_UC._isfixed[0]) fprintf(vf,"(%i",_UC.abinitioCode[0]);/*possible?*/ + else fprintf(vf,"%i",_UC.abinitioCode[0]); + for(i=1;i<(_UC._num_opt_steps);i++) { + if(_UC._isfixed[i]!=_UC._isfixed[i-1]) { + if(!_UC._isfixed[i]) fprintf(vf," (%i",_UC.abinitioCode[i]);/*has become not fixed*/ + else fprintf(vf," %i)",_UC.abinitioCode[i]);/*has become fixed (possible?)*/ + }else{ + fprintf(vf," %i",_UC.abinitioCode[i]);/*same as previous*/ + } + } + if(_UC._isfixed[_UC._num_opt_steps-1]) fprintf(vf,"\n");/*terminate on fixed ie. normal*/ + else fprintf(vf,")\n");/*terminate on non fixed*/ + fprintf(vf,"%% ENDabinit\n"); + is_w++; +//__OUT_BK_INT(abinitioCode,"ENDabinit",_UC._num_opt_steps); +} if(_UC.KresolStart!=NULL) __OUT_BK_DOUBLE(KresolStart,"Kresolend",_UC._num_opt_steps); if(_UC.vacuumSize!=NULL) __OUT_BK_DOUBLE(vacuumSize,"endVacuumSize",_UC._num_opt_steps); if(_UC.numParallelCalcs!=1) __OUT_INT(numParallelCalcs); diff --git a/src/file_uspex.h b/src/file_uspex.h index f8424e4..c2c6cde 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -176,6 +176,7 @@ typedef struct { /*4.8 Ab initio calculations*/ gint _num_opt_steps; /*HIDDEN: number of optimization steps*/ gint *abinitioCode; /*calculation code used for each optimization steps*/ + gboolean *_isfixed; /*HIDDEN: deal with parenthesis*/ gdouble *KresolStart; /*reciprocal-space resolution (2*pi*ang-1) for k-points generation*/ gdouble *vacuumSize; /*amount of vacuum added at each optimization step*/ gint numParallelCalcs; /*number of structure relaxations at a time (in parallel)*/ From 56a8aa2681b56300deec5b5342255055cb772f06 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Wed, 14 Nov 2018 15:30:10 +0900 Subject: [PATCH 47/56] file_uspex: proper handling of multiple commandExecutable lines. --- src/file_uspex.c | 20 +++++-- src/file_uspex.h | 2 + src/gui_uspex.c | 144 ++++++++++++++++++++++++++++++++++++++++++++--- src/gui_uspex.h | 5 +- 4 files changed, 157 insertions(+), 14 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 5823e29..618ba7a 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -133,6 +133,8 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.KresolStart=NULL; _UC.vacuumSize=NULL; _UC.numParallelCalcs=1; + _UC.numProcessors=1;/*undocumented*/ + _UC._isCmdList=FALSE;/*default is only 1 commandExecutable*/ _UC.commandExecutable=NULL; _UC.whichCluster=0; _UC.remoteFolder=NULL; @@ -280,7 +282,7 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ /*this should be promoted*/ #define __Q(a) #a /*some lazy defines*/ -#define __STRIP_EOL(line) for(i=0;i2); /*remove last '\n'*/ j = strlen(_UC.commandExecutable); ptr = &(_UC.commandExecutable[j]); @@ -1550,6 +1554,8 @@ void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ _DBLCP(KresolStart,_SRC._num_opt_steps); _DBLCP(vacuumSize,_SRC._num_opt_steps); _CP(numParallelCalcs); + _CP(numProcessors); + _CP(_isCmdList); _STRCP(commandExecutable);/*unsure*/ _CP(whichCluster); _STRCP(remoteFolder); @@ -1998,9 +2004,15 @@ is_w=0; is_w++; //__OUT_BK_INT(abinitioCode,"ENDabinit",_UC._num_opt_steps); } - if(_UC.KresolStart!=NULL) __OUT_BK_DOUBLE(KresolStart,"Kresolend",_UC._num_opt_steps); - if(_UC.vacuumSize!=NULL) __OUT_BK_DOUBLE(vacuumSize,"endVacuumSize",_UC._num_opt_steps); - if(_UC.numParallelCalcs!=1) __OUT_INT(numParallelCalcs); +/*do not print KresolStart if linearly = {0.2~0.08}*/ +zero_check=(_UC.KresolStart[0]!=0.2); +for(i=1;i<_UC._num_opt_steps;i++) zero_check|=(_UC.KresolStart[i]!=(0.2-(gdouble)(i)*(0.2-0.08)/(_UC._num_opt_steps-1))); + if(zero_check && (_UC.KresolStart!=NULL)) __OUT_BK_DOUBLE(KresolStart,"Kresolend",_UC._num_opt_steps); +/*do not print vacuumSize if all of them are 10. (default)*/ +zero_check=FALSE;for(i=0;i<_UC._num_opt_steps;i++) zero_check|=(_UC.vacuumSize[i]!=10.0); + if(zero_check && (_UC.vacuumSize!=NULL)) __OUT_BK_DOUBLE(vacuumSize,"endVacuumSize",_UC._num_opt_steps); + if(_UC.numParallelCalcs>1) __OUT_INT(numParallelCalcs); + if(_UC.numProcessors>1) __OUT_INT(numProcessors); /*often commandExecutable (which should be mandatory) is omitted when abinitioCode==1 (VASP)*/ if((_UC.abinitioCode[0]!=0)&&(_UC.commandExecutable!=NULL)) __OUT_BK_STRING(commandExecutable,"EndExecutable");/*let's be permissive*/ if(_UC.whichCluster!=0) __OUT_INT(whichCluster); diff --git a/src/file_uspex.h b/src/file_uspex.h index c2c6cde..b8f1558 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -180,6 +180,8 @@ typedef struct { gdouble *KresolStart; /*reciprocal-space resolution (2*pi*ang-1) for k-points generation*/ gdouble *vacuumSize; /*amount of vacuum added at each optimization step*/ gint numParallelCalcs; /*number of structure relaxations at a time (in parallel)*/ + gint numProcessors; /*how many processors per calculation - undocumented*/ + gboolean _isCmdList; /*HIDDEN: switch between only 1 commandExecutable and 1 per optimization steps*/ gchar *commandExecutable; /*executable file/command for each optimization step*/ gint whichCluster; /*type of job-submission*/ gchar *remoteFolder; /*remote folder where calculation is performed (whichCluster=2)*/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 8d4eaf7..56a430f 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -197,6 +197,19 @@ void gui_uspex_init(struct model_pak *model){ } if(uspex_gui.calc._calctype_dim==3) uspex_gui.calc.doSpaceGroup=TRUE; else uspex_gui.calc.doSpaceGroup=FALSE; + /*calculation steps specific*/ + if(uspex_gui.calc.KresolStart==NULL) { + uspex_gui.calc.KresolStart=g_malloc(uspex_gui.calc._num_opt_steps*sizeof(gdouble)); + uspex_gui.calc.KresolStart[0]=0.2; + for(idx=1;idx Date: Wed, 14 Nov 2018 21:05:24 +0900 Subject: [PATCH 48/56] gui_uspex: gui_sync 1/2 + fixes. --- src/file_uspex.h | 1 + src/gui_defs.h | 2 + src/gui_uspex.c | 347 +++++++++++++++++++++++++++++++++++++++++++++-- src/gui_uspex.h | 6 +- 4 files changed, 340 insertions(+), 16 deletions(-) diff --git a/src/file_uspex.h b/src/file_uspex.h index b8f1558..d686f74 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -228,6 +228,7 @@ typedef struct { gdouble thicknessS; /*thickness (Ang) of the surface (ie adatoms) surface region*/ gdouble thicknessB; /*thickness (Ang) of the buffer (no adatoms) surface region*/ gint reconstruct; /*max number of multiplication of the surface cell (for reconstruction)*/ + gint *StoichiometryStart; /*starting stoichiometry (undocumented)*/ /*VER 10.1 - 5.4 Clusters*/ /*no keyword in this section (selection by calculationType)*/ /*5.5 Variable composition (previously 5.3)*/ diff --git a/src/gui_defs.h b/src/gui_defs.h index 61bdcf4..5695f07 100644 --- a/src/gui_defs.h +++ b/src/gui_defs.h @@ -388,6 +388,8 @@ _Pragma ("GCC warning \"use of GTK COMBO interface is deprecated!\"");\ #define GUI_ENTRY_TEXT(entry,text) gtk_entry_set_text(GTK_ENTRY(entry),text); /*connect entry (entry) on change with the function (function) passing data (data).*/ #define GUI_ENTRY_CHANGE(entry,function,data) g_signal_connect(GTK_OBJECT(GTK_ENTRY(entry)),"changed",GTK_SIGNAL_FUNC(function),data) +/*connect entry (entry) on activation (enter key) with the function (function) passing data (data).*/ +#define GUI_ENTRY_ACTIVATE(entry,function,data) g_signal_connect(GTK_OBJECT(GTK_ENTRY(entry)),"activate",GTK_SIGNAL_FUNC(function),data) /*get the text ("text") of an entry (entry).*/ /* NEW: GTK2 says that return text is const and shall not be freed, hence the g_strdup * so text HAVE TO be freed after use.*/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 56a430f..3d5385a 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -209,6 +209,13 @@ void gui_uspex_init(struct model_pak *model){ for(idx=0;idx TODO*/ + if(uspex_gui.calc.calculationMethod==US_CM_META) USPEX_REG_VAL(ExternalPressure,"%lf"); + /*valences is special*/ + /*goodBonds is special*/ + //checkMolecules is already sync + //checkConnectivity is already sync + USPEX_REG_VAL(fitLimit,"%lf"); + USPEX_REG_VAL(populationSize,"%i"); + USPEX_REG_VAL(initialPopSize,"%i"); + USPEX_REG_VAL(numGenerations,"%i"); + USPEX_REG_VAL(stopCrit,"%i"); + USPEX_REG_VAL(bestFrac,"%lf"); + USPEX_REG_VAL(keepBestHM,"%i"); + //reoptOld is already sync + /*symmetries is special*/ + USPEX_REG_VAL(fracGene,"%lf"); + USPEX_REG_VAL(fracRand,"%lf"); + USPEX_REG_VAL(fracTopRand,"%lf"); + USPEX_REG_VAL(fracPerm,"%lf"); + USPEX_REG_VAL(fracAtomsMut,"%lf"); + USPEX_REG_VAL(fracRotMut,"%lf"); + USPEX_REG_VAL(fracLatMut,"%lf"); + USPEX_REG_VAL(fracSpinMut,"%lf"); + USPEX_REG_VAL(howManySwaps,"%i"); + USPEX_REG_TEXT(specificSwaps); + USPEX_REG_VAL(mutationDegree,"%lf"); + USPEX_REG_VAL(mutationRate,"%lf"); + USPEX_REG_VAL(DisplaceInLatmutation,"%lf"); + //AutoFrac is already sync + /*IonDistances is special*/ + USPEX_REG_VAL(minVectorLength,"%lf"); + USPEX_REG_VAL(constraint_enhancement,"%i"); + /*MolCenters is special*/ + /*Latticevalues is special*/ + /*splitInto is special*/ + //pickUpYN is already sync + USPEX_REG_VAL(pickUpGen,"%i"); + USPEX_REG_VAL(pickUpFolder,"%i"); + uspex_gui.calc._num_opt_steps=(gint)uspex_gui._tmp_num_opt_steps; + /*abinitioCode is special*/ + /*KresolStart is special*/ + /*vacuumSize is special*/ + /*_isfixed is special*/ + USPEX_REG_VAL(numParallelCalcs,"%i"); + /*commandExecutable is special*/ + USPEX_REG_VAL(whichCluster,"%i"); + USPEX_REG_TEXT(remoteFolder); + //PhaseDiagram is already sync + USPEX_REG_VAL(RmaxFing,"%lf"); + USPEX_REG_VAL(deltaFing,"%lf"); + USPEX_REG_VAL(sigmaFing,"%lf"); + USPEX_REG_VAL(antiSeedsActivation,"%i"); + USPEX_REG_VAL(antiSeedsMax,"%lf"); + USPEX_REG_VAL(antiSeedsSigma,"%lf"); + //doSpaceGroup is already sync + USPEX_REG_VAL(SymTolerance,"%lf"); + USPEX_REG_VAL(repeatForStatistics,"%i"); + USPEX_REG_VAL(stopFitness,"%lf"); + USPEX_REG_VAL(fixRndSeed,"%i"); + //collectForces is already sync + //ordering_active is already sync + //symmetrize is already sync + /*valenceElectr is special*/ + USPEX_REG_VAL(percSliceShift,"%lf"); + /*dynamicalBestHM is special*/ + USPEX_REG_TEXT(softMutOnly); + USPEX_REG_VAL(maxDistHeredity,"%lf"); + /*manyParents is special*/ + USPEX_REG_VAL(minSlice,"%lf"); + USPEX_REG_VAL(maxSlice,"%lf"); + USPEX_REG_VAL(numberparents,"%i"); + /*_nmolecules is special TODO*/ + USPEX_REG_VAL(BoltzTraP_T_max,"%lf"); + USPEX_REG_VAL(BoltzTraP_T_delta,"%lf"); + USPEX_REG_VAL(BoltzTraP_T_efcut,"%lf"); + USPEX_REG_VAL(TE_T_interest,"%lf"); + USPEX_REG_VAL(TE_threshold,"%lf"); + /*TE_goal is special*/ + USPEX_REG_VAL(thicknessS,"%lf"); + USPEX_REG_VAL(thicknessB,"%lf"); + USPEX_REG_VAL(reconstruct,"%i"); + /*StoichiometryStart is special*/ + USPEX_REG_VAL(firstGeneMax,"%i"); + USPEX_REG_VAL(minAt,"%i"); + USPEX_REG_VAL(maxAt,"%i"); + USPEX_REG_VAL(fracTrans,"%lf"); + USPEX_REG_VAL(howManyTrans,"%lf"); + /*specificTrans is special*/ + //ExternalPressure is already sync + USPEX_REG_VAL(GaussianWidth,"%lf"); + USPEX_REG_VAL(GaussianHeight,"%lf"); + /*FullRelax is special*/ + USPEX_REG_VAL(maxVectorLength,"%lf"); + USPEX_REG_VAL(PSO_softMut,"%lf"); + USPEX_REG_VAL(PSO_BestStruc,"%lf"); + USPEX_REG_VAL(PSO_BestEver,"%lf"); + USPEX_REG_VAL(vcnebType,"%i"); + /*_vcnebtype_method is special*/ + //_vcnebtype_img_num is already sync + //_vcnebtype_spring is already sync + USPEX_REG_VAL(numImages,"%i"); + USPEX_REG_VAL(numSteps,"%i"); + /*optReadImages is special*/ + /*optimizerType is special*/ + /*optRelaxType is special*/ + USPEX_REG_VAL(dt,"%lf"); + USPEX_REG_VAL(ConvThreshold,"%lf"); + USPEX_REG_VAL(VarPathLength,"%lf"); + USPEX_REG_VAL(K_min,"%lf"); + USPEX_REG_VAL(K_max,"%lf"); + USPEX_REG_VAL(Kconstant,"%lf"); + //optFreezing is already sync + /*optMethodCIDI is special*/ + USPEX_REG_VAL(startCIDIStep,"%i"); + /*pickupImages is special*/ + /*FormatType is special*/ + USPEX_REG_VAL(PrintStep,"%i"); + USPEX_REG_VAL(numIterations,"%i"); + USPEX_REG_TEXT(speciesSymbol); + /*mass is special*/ + GUI_REG_VAL(uspex_gui.amplitudeShoot_AB,uspex_gui.calc.amplitudeShoot[0],"%lf"); + GUI_REG_VAL(uspex_gui.amplitudeShoot_BA,uspex_gui.calc.amplitudeShoot[1],"%lf"); + GUI_REG_VAL(uspex_gui.magnitudeShoot_success,uspex_gui.calc.magnitudeShoot[0],"%lf"); + GUI_REG_VAL(uspex_gui.magnitudeShoot_failure,uspex_gui.calc.magnitudeShoot[1],"%lf"); + USPEX_REG_VAL(shiftRatio,"%lf"); + //orderParaType is already sync + GUI_REG_VAL(uspex_gui.opCriteria_start,uspex_gui.calc.opCriteria[0],"%lf"); + GUI_REG_VAL(uspex_gui.opCriteria_end,uspex_gui.calc.opCriteria[1],"%lf"); + USPEX_REG_TEXT(cmdOrderParameter); + USPEX_REG_TEXT(cmdEnthalpyTemperature); + USPEX_REG_TEXT(orderParameterFile); + USPEX_REG_TEXT(enthalpyTemperatureFile); + USPEX_REG_TEXT(trajectoryFile); + USPEX_REG_TEXT(MDrestartFile); + USPEX_REG_TEXT(job_path); } /***************************/ /* save current parameters */ @@ -2799,7 +3109,7 @@ GUI_TOOLTIP(uspex_gui.bestFrac,"bestFrac: Ch. 4.3 DEFAULT: 0.7\nFraction of curr GUI_TOOLTIP(uspex_gui.keepBestHM,"keepBestHM: Ch. 4.3 DEFAULT: auto\nNumber of best structures that will survive in next generation."); GUI_CHECK_TABLE(table,uspex_gui.reoptOld,uspex_gui.calc.reoptOld,NULL,"reopt",2,3,4,5);/*not calling anything*/ GUI_TOOLTIP(uspex_gui.reoptOld,"reoptOld: Ch. 4.3 DEFAULT: FALSE\nIf set surviving structure will be re-optimized."); - GUI_ENTRY_TABLE(table,uspex_gui.fitLimit,uspex_gui.calc.fitLimit,"%.4f","BestFIT:",3,4,4,5); + GUI_ENTRY_TABLE(table,uspex_gui.fitLimit,uspex_gui.calc.fitLimit,"%.4f","fitLimit:",3,4,4,5); GUI_TOOLTIP(uspex_gui.fitLimit,"fitLimit: Ch. 4.3 DEFAULT: none\nStop calculation when fitLimit fitness is reached."); /* --- Structure & Variation */ GUI_LABEL_TABLE(table,"Structure & Variation",0,4,5,6); @@ -2898,9 +3208,9 @@ GUI_TOOLTIP(uspex_gui._num_opt_steps,"Set the number of optimisation steps.\nInc GUI_SPIN_RANGE(uspex_gui._curr_step,1.,uspex_gui._tmp_num_opt_steps); GUI_TOOLTIP(uspex_gui._curr_step,"Select current optimisation step number."); GUI_CHECK_TABLE(table,button,uspex_gui.auto_step,toggle_auto_step,"AUTO STEP",2,3,1,2); -GUI_TOOLTIP(button,"For GULP- or VASP-based USPEX calculations (3~5 steps),\nuse a series of automatic settings for input.\nUser specific PS file is still needed!"); +GUI_TOOLTIP(button,"This indicates that user have a \"Specific\" directory containing\nall necessary calculation files:\nginput_N, goptions_N for GULP (for each N step)\nINCAR_N, POTCAR_X for VASP (for each step N and species X)"); GUI_CHECK_TABLE(table,uspex_gui._isfixed,uspex_gui._tmp_isfixed,toggle_isfixed,"Relax_fixed",3,4,1,2); -GUI_TOOLTIP(button,"Set the current step as a fixed relaxation.\nUseful only with a mix between fixed and full relaxations."); +GUI_TOOLTIP(uspex_gui._isfixed,"Set the current step as a fixed relaxation.\nUseful only with a mix between fixed and full relaxations."); /* line 2 */ GUI_COMBOBOX_TABLE(table,uspex_gui.abinitioCode,"CODE:",0,2,2,3); GUI_COMBOBOX_ADD(uspex_gui.abinitioCode,"0 - NONE"); @@ -2928,23 +3238,24 @@ GUI_TOOLTIP(uspex_gui.vacuumSize,"vacuumSize: Ch. 4.8 DEFAULT: 10.0\nVacuum size /* line 3 */ GUI_TEXT_TABLE(table,uspex_gui.ai_input,uspex_gui._tmp_ai_input,"INP:",0,1,3,4); GUI_TOOLTIP(uspex_gui.ai_input,"Input for the current calculation step.\nFile name as to end with *_N where N is the step number."); - GUI_OPEN_BUTTON_TABLE(table,button,load_ai_input_dialog,1,2,3,4); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.ai_input_button,load_ai_input_dialog,1,2,3,4); GUI_TEXT_TABLE(table,uspex_gui.ai_opt,uspex_gui._tmp_ai_opt,"OPT:",2,3,3,4); GUI_TOOLTIP(uspex_gui.ai_opt,"Complementary (optional) file for the current calculation step.\nWhen present, file name as to end with *_N where N is the step number."); - GUI_OPEN_BUTTON_TABLE(table,button,load_ai_opt_dialog,3,4,3,4); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.ai_opt_button,load_ai_opt_dialog,3,4,3,4); /* line 4 */ GUI_TEXT_TABLE(table,uspex_gui.commandExecutable,uspex_gui._tmp_commandExecutable,"EXE:",0,1,4,5); GUI_TOOLTIP(uspex_gui.commandExecutable,"commandExecutable: Ch. 4.8 DEFAULT: none\nCurrent optimisation step executable of submission script."); GUI_OPEN_BUTTON_TABLE(table,button,load_abinito_exe_dialog,1,2,4,5); GUI_BUTTON_TABLE(table,uspex_gui.ai_generate,"Generate",generate_step,2,3,4,5); -GUI_TOOLTIP(uspex_gui.ai_generate,"Use GDIS integrated interface to create this step input file.\nFor now, limited to VASP and GULP."); +GUI_TOOLTIP(uspex_gui.ai_generate,"Use GDIS integrated interface to create this step input file.\nUnavailable (for now) m(_ _)m"); GUI_APPLY_BUTTON_TABLE(table,button,apply_step,3,4,4,5); GUI_TOOLTIP(button,"Apply changes to this step (only)."); /* line 5 */ GUI_COMBOBOX_TABLE(table,uspex_gui.ai_spe,"Species:",0,1,5,6); - GUI_TEXT_TABLE(table,uspex_gui.ai_pot,uspex_gui._tmp_ai_pot,"POT:",1,3,5,6); -GUI_TOOLTIP(uspex_gui.ai_pot,"Per-species (pseudo-)potential files."); - GUI_OPEN_BUTTON_TABLE(table,button,load_ai_pot_dialog,3,4,5,6); +GUI_TOOLTIP(uspex_gui.ai_spe,"Select species for (pseudo-)potential information."); + GUI_TEXT_TABLE(table,uspex_gui.ai_pot,uspex_gui._potentials[0],"POT:",1,3,5,6); +GUI_TOOLTIP(uspex_gui.ai_pot,"Per-species (pseudo-)potential files.\nFor pair- and molecules-potential, do not mind the \"per-species\"."); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.ai_pot_button,load_ai_pot_dialog,3,4,5,6); /* --- USPEX launch */ GUI_LABEL_TABLE(table,"USPEX launch",0,4,6,7); /* line 7 */ @@ -3273,10 +3584,16 @@ GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (A /*per optimization step*/ GUI_COMBOBOX_SETUP(uspex_gui.abinitioCode,0,uspex_ai_selected);/*ai means ab initio, not...*/ - spin_update_curr_step(); uspex_ai_selected(uspex_gui.abinitioCode); - + GUI_LOCK(uspex_gui.ai_generate);/*Use of GDIS to prepare specific calculation parameter is Unavailable for now (TODO)*/ + GUI_LOCK(uspex_gui.ai_spe); + populate_spe(); + GUI_UNLOCK(uspex_gui.ai_spe); + GUI_COMBOBOX_SETUP(uspex_gui.ai_spe,0,ai_spe_selected); + ai_spe_selected(uspex_gui.ai_spe); + toggle_auto_step(); + GUI_ENTRY_ACTIVATE(uspex_gui.ai_pot,change_ai_pot,NULL); mag_toggle(); GUI_COMBOBOX_SETUP(uspex_gui.dynamicalBestHM,2,uspex_dyn_HM_selected); GUI_COMBOBOX_SETUP(uspex_gui.manyParents,0,uspex_manyParents_selected); diff --git a/src/gui_uspex.h b/src/gui_uspex.h index a09effd..b7aad7a 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -127,7 +127,6 @@ struct uspex_calc_gui{ gint _curr_center; GUI_OBJ *constraint_enhancement; gboolean auto_C_ion; - gboolean auto_C_lat; GUI_OBJ *_molModels; /*4.6 Cell*/ GUI_OBJ *Latticevalues; @@ -155,12 +154,17 @@ struct uspex_calc_gui{ gboolean auto_step; gchar *_tmp_ai_input; GUI_OBJ *ai_input; + GUI_OBJ *ai_input_button; gchar *_tmp_ai_opt; GUI_OBJ *ai_opt; + GUI_OBJ *ai_opt_button; GUI_OBJ *ai_generate; + gchar *_tmp_ai_spe; GUI_OBJ *ai_spe; + gchar **_potentials; gchar *_tmp_ai_pot; GUI_OBJ *ai_pot; + GUI_OBJ *ai_pot_button; GUI_OBJ *numParallelCalcs; gchar *_tmp_commandExecutable; GUI_OBJ *commandExecutable; From 2827a54f1c334a7e52a7ee76e3afa751c2dfc03e Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 15 Nov 2018 21:48:57 +0900 Subject: [PATCH 49/56] gui_uspex: gui_sync 2/3 + fixes + cosmetic changes. --- src/file_uspex.c | 9 +- src/file_uspex.h | 2 +- src/gui_uspex.c | 611 ++++++++++++++++++++++++++++++++++++----------- src/gui_uspex.h | 8 + 4 files changed, 485 insertions(+), 145 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 618ba7a..2ccafc3 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -122,6 +122,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.constraint_enhancement=TRUE; _UC._nmolecules=0; _UC.MolCenters=NULL; + _UC._nlatticevalues=0; _UC.Latticevalues=NULL; _UC.splitInto=NULL; _UC.pickUpYN=FALSE; @@ -283,7 +284,7 @@ uspex_calc_struct *read_uspex_parameters(gchar *filename,gint safe_nspecies){ #define __Q(a) #a /*some lazy defines*/ #define __STRIP_EOL(line) for(i=0;i0) { line=g_strdup(""); for(idx=0;idxnum_atoms%10)*10; @@ -195,6 +213,10 @@ void gui_uspex_init(struct model_pak *model){ uspex_gui.calc.IonDistances = g_malloc(uspex_gui.calc._nspecies*uspex_gui.calc._nspecies*sizeof(gdouble)); for(idx=0;idx should never happen*/ GUI_COMBOBOX_SET(uspex_gui.atomType,0); return; @@ -1191,7 +1276,7 @@ void apply_atom(){ g_free(text); /*add a new atomType*/ /*check if atomType does not exists*/ - index=0; + idx=0; GUI_COMBOBOX_SET(uspex_gui.atomType,0); GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); while(g_ascii_strcasecmp(text,"ADD ATOMTYPE") != 0){ @@ -1199,8 +1284,8 @@ void apply_atom(){ uspex_gui._tmp_atom_typ=elem_symbol_test(tmp); if(uspex_gui._tmp_atom_typ==typ) exists=TRUE; g_free(text); - index++; - GUI_COMBOBOX_SET(uspex_gui.atomType,index); + idx++; + GUI_COMBOBOX_SET(uspex_gui.atomType,idx); GUI_COMBOBOX_GET_TEXT(uspex_gui.atomType,text); } if(exists){ @@ -1211,8 +1296,28 @@ void apply_atom(){ }else{ text = g_strdup_printf("%s(%i) (V=%i)",sym,num,val); GUI_COMBOBOX_ADD_TEXT(uspex_gui.atomType,index,text); - GUI_COMBOBOX_SET(uspex_gui.atomType,index+1);/*select last*/ g_free(text); + /*synchronize: calc.atomType, numSpecies*/ + atomType=g_malloc((uspex_gui.calc._nspecies+1)*sizeof(gint)); + numSpecies=g_malloc((uspex_gui.calc._nspecies+1)*sizeof(gint)); + for(idx=0;idx should never happen*/ GUI_COMBOBOX_SET(uspex_gui.atomType,0); @@ -1279,8 +1390,111 @@ void remove_atom(){ return; } GUI_COMBOBOX_DEL(uspex_gui.atomType,index); + g_free(text); + /*synchronize: calc.atomType, numSpecies*/ + if(uspex_gui.calc._nspecies==1) return;/*this should never happen*/ + atomType=g_malloc((uspex_gui.calc._nspecies-1)*sizeof(gint)); + numSpecies=g_malloc((uspex_gui.calc._nspecies-1)*sizeof(gint)); + for(idx=0;idx1){ + GUI_COMBOBOX_WIPE(uspex_gui.numSpecies); + for(jdx=0;jdx should never happen*/ + GUI_COMBOBOX_SET(uspex_gui.numSpecies,0); + return; + } + if(!uspex_gui.calc._calctype_var) return;/*only varcomp allowed*/ + GUI_COMBOBOX_GET_TEXT(uspex_gui.numSpecies,text); + if (g_ascii_strcasecmp(text,"ADD SPECIES BLOCK") == 0){ + /*can't delete this one*/ + g_free(text); + return; + } + GUI_COMBOBOX_DEL(uspex_gui.numSpecies,index); + if(index-1<0) index=1; + GUI_COMBOBOX_SET(uspex_gui.goodBonds,index-1); g_free(text); } /*********************/ @@ -1851,6 +2065,8 @@ void toggle_auto_step(void){ /********************************/ void toggle_isfixed(void){ /*nothing for now*/ + gint i=(gint)uspex_gui._tmp_curr_step; + uspex_gui.calc._isfixed[i-1]=uspex_gui._tmp_isfixed; } /********************************/ /* select AI code for this step */ @@ -1897,7 +2113,7 @@ void apply_step(void){ GUI_COMBOBOX_GET(uspex_gui.abinitioCode,uspex_gui.calc.abinitioCode[i-1]); GUI_REG_VAL(uspex_gui.KresolStart,uspex_gui.calc.KresolStart[i-1],"%lf"); GUI_REG_VAL(uspex_gui.vacuumSize,uspex_gui.calc.vacuumSize[i-1],"%lf"); - + /*REG command*/ if(uspex_gui.calc._isCmdList){ /*we have 1 cmd per step*/ ptr=uspex_gui.calc.commandExecutable; @@ -1929,6 +2145,10 @@ void apply_step(void){ /*we have 1 command at all!*/ GUI_ENTRY_GET_TEXT(uspex_gui.commandExecutable,ptr); ptr2=uspex_gui.calc.commandExecutable; +if(ptr2==NULL) { + /*just copy the command*/ + uspex_gui.calc.commandExecutable=g_strdup(ptr); +}else{ while((*ptr!='\0')&&(*ptr2!='\0')&&((*ptr)==(*ptr2))) { ptr++; ptr2++; @@ -1967,6 +2187,7 @@ void apply_step(void){ } uspex_gui.calc._isCmdList=TRUE;/*change to reflect new orientation*/ } +} }/*false alarm*/ } @@ -1991,6 +2212,7 @@ void ai_spe_selected(GUI_OBJ *w){ gchar *text; gint index; GUI_COMBOBOX_GET(w,index); + if(index<0) return;/*can happen when re-populating*/ /**/ if(uspex_gui._tmp_ai_spe!=NULL) g_free(uspex_gui._tmp_ai_spe); GUI_COMBOBOX_GET_TEXT(uspex_gui.ai_spe,uspex_gui._tmp_ai_spe); @@ -2510,6 +2732,7 @@ void uspex_gui_page_switch(GUI_NOTE *notebook,GUI_OBJ *page,guint page_num){ } } else if (page_num==USPEX_PAGE_CALCULATION){ /**/ + populate_spe(); } else if (page_num==USPEX_PAGE_ADVANCED){ /**/ } else if (page_num==USPEX_PAGE_SPECIFIC){ @@ -2526,22 +2749,95 @@ void uspex_gui_page_switch(GUI_NOTE *notebook,GUI_OBJ *page,guint page_num){ /* convert current uspex_gui into uspex_calc_struct */ /****************************************************/ void uspex_gui_sync(){ + gint index; + gint idx; + gint jdx; + gchar *text; + gchar *ptr; + gchar *ptr2; + gint num; + gint val; /* sync start here */ USPEX_REG_TEXT(name); - /*calculationMethod is special*/ - /*calculationType is special*/ + //calculationMethod is already sync + //calculationType is already sync uspex_gui.calc._calctype_dim=(gint)uspex_gui._dim; - //_calctype_mol already sync - //_calctype_var already sync - //_calctype_mag already sync - /*optType is special*/ + //_calctype_mol is already sync + //_calctype_var is already sync + //_calctype_mag is already sync + //optType is already sync if(uspex_gui.have_new_opt) USPEX_REG_TEXT(new_optType); //anti_opt is already sync - /*recalculate n_species*/ - /*atomType is special*/ - /*recalculate _var_nspecies*/ - /*numSpecies is special TODO*/ - /*magRatio is special*/ + //n_species is already sync + //atomType is already sync + if(uspex_gui.calc._calctype_var){/*VARCOMP -> take numSpecies from numSpecies lines*/ + GUI_COMBOBOX_GET(uspex_gui.numSpecies,index);/*PUSH index*/ + /*count _var_nspecies*/ + idx=0; + GUI_COMBOBOX_SET(uspex_gui.numSpecies,0); + GUI_COMBOBOX_GET_TEXT(uspex_gui.numSpecies,text); + while(g_ascii_strcasecmp(text,"ADD SPECIES BLOCK") != 0){ + g_free(text); + idx++; + GUI_COMBOBOX_SET(uspex_gui.numSpecies,idx); + GUI_COMBOBOX_GET_TEXT(uspex_gui.numSpecies,text); + } + uspex_gui.calc._var_nspecies=idx; + if(uspex_gui.calc.numSpecies!=NULL) g_free(uspex_gui.calc.numSpecies); + uspex_gui.calc.numSpecies=g_malloc((uspex_gui.calc._nspecies*uspex_gui.calc._var_nspecies)*sizeof(gint)); + jdx=0; + GUI_COMBOBOX_SET(uspex_gui.numSpecies,0); + GUI_COMBOBOX_GET_TEXT(uspex_gui.numSpecies,text); + while(g_ascii_strcasecmp(text,"ADD SPECIES BLOCK") != 0){ + ptr=text; + while((*ptr!='\0')&&(!g_ascii_isgraph(*ptr))) ptr++; + idx=0; + while((idx numSpecies is a 1-line block, take it directly from atomType*/ + uspex_gui.calc._var_nspecies=1; + GUI_COMBOBOX_GET(uspex_gui.atomType,index);/*PUSH index*/ + GUI_LOCK(uspex_gui.atomType); + /*re-dim*/ + if(uspex_gui.calc.numSpecies!=NULL) g_free(uspex_gui.calc.numSpecies); + if(uspex_gui.calc.valences!=NULL) g_free(uspex_gui.calc.valences); + uspex_gui.calc.numSpecies=g_malloc((uspex_gui.calc._nspecies)*sizeof(gint)); + uspex_gui.calc.valences=g_malloc((uspex_gui.calc._nspecies)*sizeof(gint)); + for(idx=0;idx TODO*/ - if(uspex_gui.calc.calculationMethod==US_CM_META) USPEX_REG_VAL(ExternalPressure,"%lf"); - /*valences is special*/ + GUI_ENTRY_GET_TEXT(uspex_gui.ldaU,text); + num=0;ptr=text; + while(*ptr!='\0') { + if(g_ascii_isdigit(*ptr)) num++; + ptr++; + } + if(num>0){/*we have some value to sync*/ + if(uspex_gui.calc.ldaU!=NULL) g_free(uspex_gui.calc.ldaU); + uspex_gui.calc.ldaU=g_malloc((uspex_gui.calc._nspecies)*sizeof(gdouble)); + for(idx=0;idx MAX & MAX -> MIN"); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMol",2,3,8,9);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkMolecules,NULL,"ckMol",2,3,9,10);/*not calling anything*/ GUI_TOOLTIP(button,"checkMolecules: Ch. 4.1 DEFAULT: TRUE\nCheck and discard broken/merged molecules."); - GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckCon",3,4,8,9);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,uspex_gui.calc.checkConnectivity,NULL,"ckCon",3,4,9,10);/*not calling anything*/ GUI_TOOLTIP(button,"checkConnectivity: Ch. 4.1 DEFAULT: FALSE\nCalculate hardness and add connectivity in softmutation."); /* <- Ext Pressure, LDA+U, and magRation moved to p. III, II, and III, respectively.*/ /* --- cell */ - GUI_LABEL_TABLE(table,"Cell",0,4,9,10); -/* line 10 */ - GUI_COMBOBOX_TABLE(table,uspex_gui.Latticevalues,"Lattice:",0,1,10,11);/*multiline*/ + GUI_LABEL_TABLE(table,"Cell",0,4,10,11); +/* line 11 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.Latticevalues,"Lattice:",0,1,11,12);/*multiline*/ GUI_TOOLTIP(uspex_gui.Latticevalues,"Latticevalues: Ch. 4.6 DEFAULT: auto\nInitial volume of the unit cell, or known lattice parameters."); - GUI_TEXT_TABLE(table,uspex_gui._latticevalue,uspex_gui._tmp_latticevalue,"VALUES:",1,3,10,11); + GUI_TEXT_TABLE(table,uspex_gui._latticevalue,uspex_gui._tmp_latticevalue,"VALUES:",1,3,11,12); GUI_TOOLTIP(uspex_gui._latticevalue,"VALUES: values of the current line of Latticevalues."); - GUI_APPLY_BUTTON_TABLE(table,button,apply_latticevalue,3,4,10,11); -/* line 11 */ - /*col 1: empty*/ - GUI_COMBOBOX_TABLE(table,uspex_gui._latticeformat,"FORMAT:",1,2,11,12); + GUI_APPLY_BUTTON_TABLE(table,button,apply_latticevalue,3,4,11,12); +/* line 12 */ + GUI_COMBOBOX_TABLE(table,uspex_gui._latticeformat,"FORMAT:",0,1,12,13); + /*col 2: empty*/ GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Volumes"); GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Lattice"); GUI_COMBOBOX_ADD(uspex_gui._latticeformat,"Crystal"); GUI_TOOLTIP(uspex_gui._latticeformat,"FORMAT: whether Lattice values correspond to a series of\nVolumes, lattive vectors, or crystallographic definition."); - GUI_TEXT_TABLE(table,uspex_gui.splitInto,uspex_gui._tmp_splitInto,"split:",2,3,11,12); + GUI_TEXT_TABLE(table,uspex_gui.splitInto,uspex_gui._tmp_splitInto,"split:",1,3,12,13); GUI_TOOLTIP(uspex_gui.splitInto,"splitInto: Ch. 4.5 DEFAULT: 1\nNumber of identical subcells or pseudosubcells in the unitcell."); - GUI_CHECK_TABLE(table,button,uspex_gui.auto_lval,toggle_auto_lval,"AUTO_LAT",3,4,11,12); + GUI_CHECK_TABLE(table,button,uspex_gui.auto_lval,toggle_auto_lval,"AUTO_LAT",3,4,12,13); GUI_TOOLTIP(button,"AUTO_LAT: use automatic value for Latticevalues."); /* Constraints */ - GUI_LABEL_TABLE(table,"Constraints",0,4,12,13); -/* line 13 */ - GUI_COMBOBOX_TABLE(table,uspex_gui.IonDistances,"Ion:",0,1,13,14);/*multiline*/ + GUI_LABEL_TABLE(table,"Constraints",0,4,13,14); +/* line 14 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.IonDistances,"Ion:",0,1,14,15);/*multiline*/ GUI_TOOLTIP(uspex_gui.IonDistances,"IonDistance: Ch. 4.5 DEFAULT: auto\nTriangular matrix of the minimum allowed\ninteratomic distances."); - GUI_TEXT_TABLE(table,uspex_gui._distances,uspex_gui._tmp_distances,"DIST: ",1,3,13,14); + GUI_TEXT_TABLE(table,uspex_gui._distances,uspex_gui._tmp_distances,"DIST: ",1,3,14,15); GUI_TOOLTIP(uspex_gui._distances,"distances: minimum allowed distance from the current atom to others."); - GUI_APPLY_BUTTON_TABLE(table,button,apply_distances,3,4,13,14); -/* line 14 */ + GUI_APPLY_BUTTON_TABLE(table,button,apply_distances,3,4,14,15); +/* line 15 */ /*col 1: empty*/ - GUI_ENTRY_TABLE(table,uspex_gui.minVectorLength,uspex_gui.calc.minVectorLength,"%.4f","MV:",1,2,14,15); + GUI_ENTRY_TABLE(table,uspex_gui.minVectorLength,uspex_gui.calc.minVectorLength,"%.4f","MV:",1,2,15,16); GUI_TOOLTIP(uspex_gui.minVectorLength,"minVectorLength: Ch. 4.5 DEFAULT: auto\nMinimum length of a new lattice parameter."); - GUI_ENTRY_TABLE(table,uspex_gui.constraint_enhancement,uspex_gui.calc.constraint_enhancement,"%i","CE:",2,3,14,15); + GUI_ENTRY_TABLE(table,uspex_gui.constraint_enhancement,uspex_gui.calc.constraint_enhancement,"%i","CE:",2,3,15,16); GUI_TOOLTIP(uspex_gui.constraint_enhancement,"constraint_enhancement: Ch. 4.5 DEFAULT: 1\nApply CE times the IonDistance constraints."); - GUI_CHECK_TABLE(table,button,uspex_gui.auto_C_ion,toggle_auto_C_ion,"AUTO_ION",3,4,14,15); + GUI_CHECK_TABLE(table,button,uspex_gui.auto_C_ion,toggle_auto_C_ion,"AUTO_ION",3,4,15,16); GUI_TOOLTIP(button,"AUTO_ION: use automatic values for ion constraints."); -/* line 15 */ - GUI_COMBOBOX_TABLE(table,uspex_gui.MolCenters,"Mol:",0,1,15,16);/*multiline*/ +/* line 16 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.MolCenters,"Mol:",0,1,16,17);/*multiline*/ GUI_TOOLTIP(uspex_gui.MolCenters,"MolCenters: Ch. 4.5 DEFAULT: none\nTriangular matrix of the minimum allowed\ndistances between molecules centers."); - GUI_TEXT_TABLE(table,uspex_gui._centers,uspex_gui._tmp_centers,"CENTER:",1,3,15,16); + GUI_TEXT_TABLE(table,uspex_gui._centers,uspex_gui._tmp_centers,"CENTER:",1,3,16,17); GUI_TOOLTIP(uspex_gui._centers,"centers: minimum allowed distance from the current molecule center to others."); - GUI_APPLY_BUTTON_TABLE(table,button,apply_centers,3,4,15,16); -/* line 16 */ + GUI_APPLY_BUTTON_TABLE(table,button,apply_centers,3,4,16,17); +/* line 17 */ /*col 1: empty*/ - GUI_COMBOBOX_TABLE(table,uspex_gui._molModels,"Model:",1,3,16,17);/*NEW*/ + GUI_COMBOBOX_TABLE(table,uspex_gui._molModels,"Model:",1,3,17,18);/*NEW*/ GUI_COMBOBOX_ADD(uspex_gui._molModels,"UNDER CONSTRUCTION"); GUI_TOOLTIP(uspex_gui._centers,"Associate each molecule with a GDIS model."); /*col 4: empty*/ -/* line 17: empty */ - GUI_LABEL_TABLE(table," ",0,4,17,18); /* --- end page */ /*---------------------*/ @@ -3425,8 +3748,11 @@ GUI_TOOLTIP(uspex_gui.MDrestartFile,"MDrestartFile: Ch. 6.2 DEFAULT: traj.restar /* --- Metadynamics */ GUI_LABEL_TABLE(table,"Metadynamics",0,4,0,1); /* line 1 */ - GUI_ENTRY_TABLE(table,uspex_gui.ExternalPressure,uspex_gui.calc.ExternalPressure,"%.4f","ExtP:",0,1,1,2); -GUI_TOOLTIP(uspex_gui.ExternalPressure,"ExternalPressure: Ch. 4.1, 5.6 DEFAULT: none\nExternal pressure (GPa) for calculation."); + GUI_COMBOBOX_TABLE(table,uspex_gui.FullRelax,"Relax:",0,1,1,2); + GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"0 - No full relaxation (fix cells)"); + GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"1 - Relax only the best structures"); + GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"2 - Relax all different structures"); +GUI_TOOLTIP(uspex_gui.FullRelax,"FullRelax: Ch. 5.6 DEFAULT: 2\nPerform full relaxation of which structures for analysis.\nRecommended value is 2."); GUI_ENTRY_TABLE(table,uspex_gui.maxVectorLength,uspex_gui.calc.maxVectorLength,"%.4f","MaxV:",1,2,1,2); GUI_TOOLTIP(uspex_gui.maxVectorLength,"maxVectorLength: Ch. 5.6 DEFAULT: none\nAdd a correction force to keep cell length below this setting."); GUI_ENTRY_TABLE(table,uspex_gui.GaussianWidth,uspex_gui.calc.GaussianWidth,"%.4f","GaussW:",2,3,1,2); @@ -3434,16 +3760,14 @@ GUI_TOOLTIP(uspex_gui.GaussianWidth,"GaussianWidth: Ch. 5.6 DEFAULT: AUTO\nWidth GUI_ENTRY_TABLE(table,uspex_gui.GaussianHeight,uspex_gui.calc.GaussianHeight,"%.4f","GaussH:",3,4,1,2); GUI_TOOLTIP(uspex_gui.GaussianHeight,"GaussianHeight: Ch. 5.6 DEFAULT: AUTO\nHeight of Gaussian added to PES to accelerate phase transition.\nRecommended values is L.dh^2.G with L = average cell length,\ndh = GaussW, and G = shear modulus."); /* line 2 */ - GUI_COMBOBOX_TABLE(table,uspex_gui.meta_model,"MODEL:",0,2,2,3); + /*col 1: empty*/ +// GUI_ENTRY_TABLE(table,uspex_gui.ExternalPressure,uspex_gui.calc.ExternalPressure,"%.4f","ExtP:",0,1,2,3); +//GUI_TOOLTIP(uspex_gui.ExternalPressure,"ExternalPressure: Ch. 4.1, 5.6 DEFAULT: none\nExternal pressure (GPa) for calculation."); + GUI_COMBOBOX_TABLE(table,uspex_gui.meta_model,"MODEL:",1,3,2,3); GUI_COMBOBOX_ADD(uspex_gui.meta_model,"From POSCAR FILE"); GUI_COMBOBOX_ADD(uspex_gui.meta_model,"UNDER CONSTRUCTION"); GUI_TOOLTIP(uspex_gui.meta_model,"Select the model from which metadynamics is started.\nA good structure, relaxed at ExtP is necessary."); - GUI_OPEN_BUTTON_TABLE(table,uspex_gui.meta_model_button,load_meta_start_file,2,3,2,3); - GUI_COMBOBOX_TABLE(table,uspex_gui.FullRelax,"Relax:",3,4,2,3); - GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"0 - No full relaxation (fix cells)"); - GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"1 - Relax only the best structures"); - GUI_COMBOBOX_ADD(uspex_gui.FullRelax,"2 - Relax all different structures"); -GUI_TOOLTIP(uspex_gui.FullRelax,"FullRelax: Ch. 5.6 DEFAULT: 2\nPerform full relaxation of which structures for analysis.\nRecommended value is 2."); + GUI_OPEN_BUTTON_TABLE(table,uspex_gui.meta_model_button,load_meta_start_file,3,4,2,3); /* --- Particles Swarm optimization */ GUI_LABEL_TABLE(table,"Particles Swarm optimization",0,4,3,4); /* line 4 */ @@ -3457,37 +3781,34 @@ GUI_TOOLTIP(uspex_gui.PSO_BestEver,"PSO_BestEver: Ch. 5.7 DEFAULT: 1\nWeight of /* --- Variable-cell nudged elastic band */ GUI_LABEL_TABLE(table,"Variable-cell nudged elastic band",0,4,5,6); /* line 6 */ - GUI_ENTRY_TABLE(table,uspex_gui.vcnebType,uspex_gui.calc.vcnebType,"%3i","VC-NEB:",0,1,6,7); -GUI_TOOLTIP(uspex_gui.vcnebType,"vcnebType: Ch. 6.1 DEFAULT: 110\nType of VC-NEB calculation."); - GUI_LOCK(uspex_gui.vcnebType);/*not directly modifiable*/ - GUI_COMBOBOX_TABLE(table,uspex_gui._vcnebtype_method,"Method:",1,2,6,7); + GUI_COMBOBOX_TABLE(table,uspex_gui._vcnebtype_method,"Method:",0,1,6,7); GUI_COMBOBOX_ADD(uspex_gui._vcnebtype_method,"1 - VC-NEB method"); GUI_COMBOBOX_ADD(uspex_gui._vcnebtype_method,"2 - simple relaxation"); GUI_TOOLTIP(uspex_gui._vcnebtype_method,"Choose between VC-NEB method and simple structure relaxation."); + GUI_ENTRY_TABLE(table,uspex_gui.vcnebType,uspex_gui.calc.vcnebType,"%3i","VC-NEB:",1,2,6,7); +GUI_TOOLTIP(uspex_gui.vcnebType,"vcnebType: Ch. 6.1 DEFAULT: 110\nType of VC-NEB calculation."); +GUI_LOCK(uspex_gui.vcnebType);/*not directly modifiable*/ GUI_CHECK_TABLE(table,uspex_gui._vcnebtype_img_num,uspex_gui.calc._vcnebtype_img_num,update_vcnebType,"Var_Image",2,3,6,7); GUI_TOOLTIP(uspex_gui._vcnebtype_img_num,"Set whether number of images should be kept fixed."); GUI_CHECK_TABLE(table,uspex_gui._vcnebtype_spring,uspex_gui.calc._vcnebtype_spring,update_vcnebType,"Var_Spring",3,4,6,7); GUI_TOOLTIP(uspex_gui._vcnebtype_spring,"Set whether spring constants should be kept fixed."); /* line 7 */ - GUI_ENTRY_TABLE(table,uspex_gui.numImages,uspex_gui.calc.numImages,"%i","N_Img:",0,1,7,8); -GUI_TOOLTIP(uspex_gui.numImages,"numImages: Ch. 6.1 DEFAULT: 9\nInitial number of images."); - GUI_COMBOBOX_TABLE(table,uspex_gui.optReadImages,"Img:",1,2,7,8); + GUI_COMBOBOX_TABLE(table,uspex_gui.optReadImages,"Img:",0,1,7,8); GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"0 - All structures are needed"); GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"1 - Only initial and final"); GUI_COMBOBOX_ADD(uspex_gui.optReadImages,"2 - Initial and final + intermediates"); GUI_TOOLTIP(uspex_gui.optReadImages,"optReadImages: Ch. 6.1 DEFAULT: 2\nSet the method for reading Images file."); - GUI_COMBOBOX_TABLE(table,uspex_gui.optimizerType,"Opt:",2,3,7,8); + GUI_ENTRY_TABLE(table,uspex_gui.numImages,uspex_gui.calc.numImages,"%i","N_Img:",1,2,7,8); +GUI_TOOLTIP(uspex_gui.numImages,"numImages: Ch. 6.1 DEFAULT: 9\nInitial number of images."); + GUI_ENTRY_TABLE(table,uspex_gui.numSteps,uspex_gui.calc.numSteps,"%4i","N_Step:",2,3,7,8); +GUI_TOOLTIP(uspex_gui.numSteps,"numSteps: Ch. 6.1 DEFAULT: 600\nMaximum VC-NEB step iterations.\nA value of at least 500 is recommended."); + GUI_CHECK_TABLE(table,uspex_gui.optFreezing,uspex_gui.calc.optFreezing,NULL,"Freeze_Img",3,4,7,8);/*not calling anything*/ +GUI_TOOLTIP(uspex_gui.optFreezing,"optFreezing: Ch. 6.1 DEFAULT: FALSE\nActivate freezing of Image structure when ConvThreshold is reached."); +/* line 8 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.optimizerType,"Opt:",0,1,8,9); GUI_COMBOBOX_ADD(uspex_gui.optimizerType,"1 - Steepest Descent"); GUI_COMBOBOX_ADD(uspex_gui.optimizerType,"2 - Fast Inertial Relaxation Engine"); GUI_TOOLTIP(uspex_gui.optimizerType,"optimizerType: Ch. 6.1 DEFAULT: 1\nSelect the optimization algorithm (SD or FIRE)."); - GUI_COMBOBOX_TABLE(table,uspex_gui.optRelaxType,"Relax:",3,4,7,8); - GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"1 - fixed cell, positions relaxed (=NEB)"); - GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"2 - cell lattice only (only for testing)"); - GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"3 - full, cell and positions relaxation."); -GUI_TOOLTIP(uspex_gui.optRelaxType,"optRelaxType: Ch. 6.1 DEFAULT: 3>\nStructure relaxation mode."); -/* line 8 */ - GUI_ENTRY_TABLE(table,uspex_gui.numSteps,uspex_gui.calc.numSteps,"%4i","N_Step:",0,1,8,9); -GUI_TOOLTIP(uspex_gui.numSteps,"numSteps: Ch. 6.1 DEFAULT: 600\nMaximum VC-NEB step iterations.\nA value of at least 500 is recommended."); GUI_ENTRY_TABLE(table,uspex_gui.dt,uspex_gui.calc.dt,"%.4f","dt:",1,2,8,9); GUI_TOOLTIP(uspex_gui.dt,"dt: Ch. 6.1 DEFAULT: 0.05\nTime step for structure relaxation."); GUI_ENTRY_TABLE(table,uspex_gui.ConvThreshold,uspex_gui.calc.ConvThreshold,"%.4f","Conv:",2,3,8,9); @@ -3495,8 +3816,11 @@ GUI_TOOLTIP(uspex_gui.ConvThreshold,"ConvThreshold: Ch. 6.1 DEFAULT: 0.003\nHalt GUI_ENTRY_TABLE(table,uspex_gui.VarPathLength,uspex_gui.calc.VarPathLength,"%.4f","PathLength:",3,4,8,9); GUI_TOOLTIP(uspex_gui.VarPathLength,"VarPathLength: Ch. 6.1 DEFAULT: AUTO\nCriterion to determine image creation/deletion for variable image method.\nif L>1.5*criterion image is added\nif L<0.5*criterion image is deleted\nL=length between two neighbor images."); /* line 9 */ - GUI_CHECK_TABLE(table,uspex_gui.optFreezing,uspex_gui.calc.optFreezing,NULL,"Freeze_Img",0,1,9,10);/*not calling anything*/ -GUI_TOOLTIP(uspex_gui.optFreezing,"optFreezing: Ch. 6.1 DEFAULT: FALSE\nActivate freezing of Image structure when ConvThreshold is reached."); + GUI_COMBOBOX_TABLE(table,uspex_gui.optRelaxType,"Relax:",0,1,9,10); + GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"1 - fixed cell, positions relaxed (=NEB)"); + GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"2 - cell lattice only (only for testing)"); + GUI_COMBOBOX_ADD(uspex_gui.optRelaxType,"3 - full, cell and positions relaxation."); +GUI_TOOLTIP(uspex_gui.optRelaxType,"optRelaxType: Ch. 6.1 DEFAULT: 3>\nStructure relaxation mode."); GUI_ENTRY_TABLE(table,uspex_gui.K_min,uspex_gui.calc.K_min,"%.4f","Kmin:",1,2,9,10); GUI_TOOLTIP(uspex_gui.K_min,"K_min: Ch. 6.1 DEFAULT: 5\nMinimum spring constant (eV/Ang.^2)."); GUI_ENTRY_TABLE(table,uspex_gui.K_max,uspex_gui.calc.K_max,"%.4f","Kmax:",2,3,9,10); @@ -3514,14 +3838,14 @@ GUI_TOOLTIP(uspex_gui.optMethodCIDI,"optMethodCIDI: Ch. 6.1 DEFAULT: 0\nOption f GUI_TOOLTIP(uspex_gui.startCIDIStep,"startCIDIStep: Ch. 6.1 DEFAULT: 100\nStarting step for CI/DI method."); GUI_TEXT_TABLE(table,uspex_gui.pickupImages,uspex_gui._tmp_pickupImages,"Pickup:",2,3,10,11); GUI_TOOLTIP(uspex_gui.pickupImages,"pickupImages: Ch. 6.1 DEFAULT: AUTO\nNumber/which images to be picked up for CI/DI method."); - GUI_COMBOBOX_TABLE(table,uspex_gui.FormatType,"Format:",3,4,10,11); + GUI_ENTRY_TABLE(table,uspex_gui.PrintStep,uspex_gui.calc.PrintStep,"%i","PrintStep:",3,4,10,11); +GUI_TOOLTIP(uspex_gui.PrintStep,"PrintStep: Ch. 6.1 DEFAULT: 1\nSave restart file every PrintStep times."); +/* line 11 */ + GUI_COMBOBOX_TABLE(table,uspex_gui.FormatType,"Format:",0,1,11,12); GUI_COMBOBOX_ADD(uspex_gui.FormatType,"1 - XCRYSTDENS format (.xsf)"); GUI_COMBOBOX_ADD(uspex_gui.FormatType,"2 - VASP v5 (POSCAR) format."); GUI_COMBOBOX_ADD(uspex_gui.FormatType,"3 - XYZ format with lattice."); GUI_TOOLTIP(uspex_gui.FormatType,"FormatType: Ch. 6.1 DEFAULT: 2\nFormat of structures in PATH output directory."); -/* line 11 */ - GUI_ENTRY_TABLE(table,uspex_gui.PrintStep,uspex_gui.calc.PrintStep,"%i","PrintStep:",0,1,11,12); -GUI_TOOLTIP(uspex_gui.PrintStep,"PrintStep: Ch. 6.1 DEFAULT: 1\nSave restart file every PrintStep times."); GUI_COMBOBOX_TABLE(table,uspex_gui.img_model,"Model:",1,3,11,12); GUI_COMBOBOX_ADD(uspex_gui.img_model,"From Images file"); GUI_COMBOBOX_ADD(uspex_gui.img_model,"UNDER CONSTRUCTION"); @@ -3580,6 +3904,9 @@ GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (A GUI_COMBOBOX_SETUP(uspex_gui._latticeformat,1,uspex_latticeformat_selected); uspex_latticeformat_selected(uspex_gui._latticeformat); SG_toggle(); + set_numSpecies(); + GUI_COMBOBOX_SETUP(uspex_gui.numSpecies,0,uspex_numSpecies_selected); + uspex_numSpecies_selected(uspex_gui.numSpecies); /*calculation*/ /*per optimization step*/ diff --git a/src/gui_uspex.h b/src/gui_uspex.h index b7aad7a..b61e934 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -75,6 +75,12 @@ struct uspex_calc_gui{ gint _tmp_atom_typ; gint _tmp_atom_num; gint _tmp_atom_val; + /*numSpecies block*/ + GUI_OBJ *numSpecies; + gchar *_tmp_blockSpecies; + GUI_OBJ *blockSpecies; + GUI_OBJ *Species_apply_button; + GUI_OBJ *Species_delete_button; /*bond definition: apply/auto*/ GUI_OBJ *goodBonds; GUI_OBJ *_bond_d; @@ -83,6 +89,8 @@ struct uspex_calc_gui{ //checkMolecules is auto-sync //checkConnectivity is auto-sync GUI_OBJ *fitLimit; /*VER 10.1*/ + gchar *_tmp_ldaU; /*VER 10.1*/ + GUI_OBJ *ldaU; /*VER 10.1*/ /*4.2 Population*/ GUI_OBJ *populationSize; GUI_OBJ *initialPopSize; From 39f46c848a71bba3cc2e3ea120991590425567a6 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Fri, 16 Nov 2018 19:08:13 +0900 Subject: [PATCH 50/56] gui_uspex: fix Latticevalues. --- src/file_uspex.c | 144 ++++++++-------- src/file_uspex.h | 3 +- src/gui_uspex.c | 415 ++++++++++++++++++++++++++++------------------- src/gui_uspex.h | 2 +- 4 files changed, 315 insertions(+), 249 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 2ccafc3..3aa859f 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -122,7 +122,8 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.constraint_enhancement=TRUE; _UC._nmolecules=0; _UC.MolCenters=NULL; - _UC._nlatticevalues=0; + _UC._nlattice_line=0; + _UC._nlattice_vals=0; _UC.Latticevalues=NULL; _UC.splitInto=NULL; _UC.pickUpYN=FALSE; @@ -901,80 +902,65 @@ else n_size=_UC._nspecies; /*count first line number of items*/ ptr=&(line[0]); while(*ptr==' ') ptr++; - _UC._nlatticevalues=1; + _UC._nlattice_vals=1; while(*ptr!='\0'){ if(*ptr==' ') { - _UC._nlatticevalues++;ptr++; + _UC._nlattice_vals++;ptr++; while(g_ascii_isgraph(*ptr)) ptr++; }else ptr++; } - /*depending on varcomp*/ - if(_UC._calctype_var){ - /*varcomp calculation: should be only one line*/ + /*count the number of lines*/ + _UC._nlattice_line=1; + while(find_in_string("Endvalues",line) != NULL){ + _UC._nlattice_line++; g_free(line);line = file_read_line(vf);/*go next line*/ - if(find_in_string("Endvalues",line) != NULL){/*only volumes values*/ - _UC.Latticevalues = g_malloc(_UC._nlatticevalues*sizeof(gdouble)); - for(i=0;i<_UC._nlatticevalues;i++) _UC.Latticevalues[i]=0.; - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - g_free(line);line = file_read_line(vf);/*go next line*/ - ptr=&(line[0]);ptr2=ptr;i=0; - while((*ptr!='\n')&&(*ptr!='\0')){ - __SKIP_BLANK(ptr); - _UC.Latticevalues[i]=g_ascii_strtod(ptr,&ptr2); - ptr=ptr2+1; - i++; - } - }else{/*varcomp but more than one line -> bad setting*/ - g_free(line); - line = g_strdup_printf("ERROR: USPEX bad Latticevalues volumes settings in varcomp Parameters.txt!\n"); - gui_text_show(ERROR, line); - g_free(line);line = file_read_line(vf);/*go next line*/ - } + } + g_free(line);fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ + /*Issue some warning on undefined cases*/ + line = g_strdup_printf("WARNING: USPEX BAD Latticevalues parameter!\n"); + if(_UC._calctype_var){ + if((_UC._nlattice_line>1)||(_UC._nlattice_vals!=_UC._var_nspecies)) + gui_text_show(WARNING, line); }else{ - /*NOT varcomp calculation: should be a crystal definition*/ - if(_UC._nlatticevalues==6){/*crystal definition -- should we test for Endvalues?*/ - _UC.Latticevalues = g_malloc(_UC._nlatticevalues*sizeof(gdouble)); - for(i=0;i<_UC._nlatticevalues;i++) _UC.Latticevalues[i]=0.; - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - g_free(line);line = file_read_line(vf);/*go next line*/ - ptr=&(line[0]);ptr2=ptr;i=0; - while((*ptr!='\n')&&(*ptr!='\0')){ - __SKIP_BLANK(ptr); - _UC.Latticevalues[i]=g_ascii_strtod(ptr,&ptr2); - ptr=ptr2+1; - i++; - } - }else if((_UC._nlatticevalues<=3)&&(_UC._nlatticevalues>1)){/*lattice vectors*/ - _UC.Latticevalues = g_malloc(_UC._nlatticevalues*_UC._nlatticevalues*sizeof(gdouble)); - for(i=0;i<_UC._nlatticevalues*_UC._nlatticevalues;i++) _UC.Latticevalues[i]=0.; - fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ - g_free(line);line = file_read_line(vf);/*go next line*/ - ptr=&(line[0]); - j=0; - while((j<_UC._nlatticevalues)&&(find_in_string("Endvalues",line)==NULL)){ - ptr=&(line[0]);ptr2=ptr;i=0; - while((*ptr!='\n')&&(*ptr!='\0')){ - __SKIP_BLANK(ptr); - _UC.Latticevalues[i+j*_UC._nlatticevalues]=g_ascii_strtod(ptr,&ptr2); - ptr=ptr2+1; - i++; + switch(_UC._nlattice_line){ + case 1: + switch(_UC._nlattice_vals){ + case 1: + break;/*always ok*/ + case 6: + if(_UC._calctype_dim==3) break; + case 3: + if(_UC._calctype_dim==2) break; + case 0:/*cannot happen*/ + default: + gui_text_show(WARNING, line); } - j++; - g_free(line); - line = file_read_line(vf); - } - }else if(_UC._nlatticevalues==1){/*only the volume value*/ - _UC.Latticevalues = g_malloc(sizeof(gdouble)); - _UC.Latticevalues[0]=0.; - _UC.Latticevalues[0]=g_ascii_strtod(ptr,NULL); - g_free(line); - line = file_read_line(vf); - }else{/*bad setting*/ - g_free(line); - line = g_strdup_printf("ERROR: USPEX bad Latticevalues setting in Parameters.txt!\n"); - gui_text_show(ERROR, line); - g_free(line);line = file_read_line(vf);/*go next line*/ + break; + case 2: + if(_UC._nlattice_vals!=2) gui_text_show(WARNING, line); + break; + case 3: + if(_UC._nlattice_vals!=3) gui_text_show(WARNING, line); + break; + default: + gui_text_show(WARNING, line); + } + } + g_free(line);line = file_read_line(vf);/*go next line*/ + _UC.Latticevalues = g_malloc(_UC._nlattice_vals*_UC._nlattice_line*sizeof(gdouble)); + for(j=0;j<_UC._nlattice_vals*_UC._nlattice_line;j++) _UC.Latticevalues[j]=0.; + j=0; + while(find_in_string("Endvalues",line) == NULL){ + ptr=&(line[0]); + i=0; + while((*ptr!='\n')&&(*ptr!='\0')){ + __SKIP_BLANK(ptr); + _UC.Latticevalues[i+j*_UC._nlattice_line]=g_ascii_strtod(ptr,&ptr2); + ptr=ptr2+1; + i++; } + j++; + g_free(line);line = file_read_line(vf); } g_free(line); line = file_read_line(vf); @@ -1536,14 +1522,14 @@ void copy_uspex_parameters(uspex_calc_struct *src,uspex_calc_struct *dest){ _CP(constraint_enhancement); _CP(_nmolecules); _DBLCP(MolCenters,_SRC._nmolecules); - _CP(_nlatticevalues); - if(_SRC._calctype_var){ - _DBLCP(Latticevalues,_SRC._nlatticevalues); - }else{ - if(_SRC._nlatticevalues==6) _DBLCP(Latticevalues,6); - else if(_SRC._nlatticevalues<=3) _DBLCP(Latticevalues,_SRC._nlatticevalues*_SRC._nlatticevalues); - else if(_SRC._nlatticevalues==1) _DBLCP(Latticevalues,1); - } + _CP(_nlattice_line); + _CP(_nlattice_vals); +if(_SRC._nlattice_line==0){ + _CP(Latticevalues);/*ie copy "NULL"*/ +}else{ + if(_SRC._calctype_var) _DBLCP(Latticevalues,_SRC._nlattice_vals); + else _DBLCP(Latticevalues,_SRC._nlattice_line*_SRC._nlattice_vals); +} _CP(_nsplits); _COPY(splitInto,_SRC._nsplits,gint); _CP(pickUpYN); @@ -1964,13 +1950,13 @@ is_w=0; __TITLE(line); g_free(line); if((_UC.calculationMethod != US_CM_VCNEB)&&(_UC.calculationMethod != US_CM_TPS)){ - if(_UC.Latticevalues!=NULL){ + if((_UC._nlattice_line>0)&&(_UC.Latticevalues!=NULL)){ if(_UC._calctype_var) { /*should be 1 line*/ - __OUT_BK_DOUBLE(Latticevalues,"Endvalues",_UC._nlatticevalues); - }else{/*more than one line if 1<_UC._nlatticevalues<=3*/ - if((_UC._nlatticevalues>1)&&(_UC._nlatticevalues<=3)) __OUT_TMAT_DOUBLE(Latticevalues,"Endvalues",_UC._nlatticevalues); - else __OUT_BK_DOUBLE(Latticevalues,"Endvalues",_UC._nlatticevalues); + __OUT_BK_DOUBLE(Latticevalues,"Endvalues",_UC._nlattice_vals); + }else{/*if more than one line -> rectangular matrix*/ + if(_UC._nlattice_line>1) __OUT_TMAT_DOUBLE(Latticevalues,"Endvalues",_UC._nlattice_vals); + else __OUT_BK_DOUBLE(Latticevalues,"Endvalues",_UC._nlattice_vals); } } if(_UC.splitInto!=NULL) __OUT_BK_INT(splitInto,"EndSplitInto",_UC._nsplits); diff --git a/src/file_uspex.h b/src/file_uspex.h index 9a06ed2..9fb74ee 100644 --- a/src/file_uspex.h +++ b/src/file_uspex.h @@ -165,7 +165,8 @@ typedef struct { gint _nmolecules; /*HIDDEN: number of molecules*/ gdouble *MolCenters; /*triangular-matrix of minimal distances between centers of molecules*/ /*4.6 Cell*/ - gint _nlatticevalues; /*HIDDEN: number of lines in Latticevalues*/ + gint _nlattice_line; /*HIDDEN: number of lines in Latticevalues*/ + gint _nlattice_vals; /*HIDDEN: number of elements per lines*/ gdouble *Latticevalues; /*initial volume/parameter of the unit cell*/ gint _nsplits; /*HIDDEN: number of splits*/ gint *splitInto; /*number of subcells into which unit cell is split*/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index a6b7a63..d3ace6f 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -212,10 +212,17 @@ void gui_uspex_init(struct model_pak *model){ if(uspex_gui.calc.IonDistances==NULL){ uspex_gui.calc.IonDistances = g_malloc(uspex_gui.calc._nspecies*uspex_gui.calc._nspecies*sizeof(gdouble)); for(idx=0;idx=6){/*drop every values over the 6th*/ - ptr=g_strdup_printf("%4f %4f %4f %4f %4f %4f",lval[0],lval[1],lval[2],lval[3],lval[4],lval[5]); - }else if(nlval==4){/*special definition*/ - ptr=g_strdup_printf("%4f %4f %4f %4f %4f %4f",lval[0],lval[1],0.,lval[2],lval[3],0.); - }else{/*zero padded*/ - ptr2=g_strdup_printf("%4f",lval[0]); - for(i=1;i1 is valid*/ - ptr2=g_strdup_printf("%4f",lval[0]); - ptr=ptr2; - for(i=1;i1){ + /*matrix has to be rectangular*/ + ptr=uspex_gui._tmp_latticevalue; + nvals=0; + while((*ptr!='\0')&&(!g_ascii_isgraph(*ptr))) ptr++; + while((*ptr!='\0')&&(nvals0){ + text=g_strdup_printf("%4f",uspex_gui.calc.Latticevalues[0]); + for(idx=0;idx lattice*/ + switch (index){ + case 1://lattice parameters + if((uspex_gui.calc._calctype_dim==3)&&(uspex_gui.calc._nlattice_line==3)&&(uspex_gui.calc._nlattice_vals==3)){ + /*do not wipe*/ + }else if((uspex_gui.calc._calctype_dim==2)&&(uspex_gui.calc._nlattice_line==2)&&(uspex_gui.calc._nlattice_vals==2)){ + /*do not wipe*/ + }else{ + /*wipe*/ + if(uspex_gui.calc._calctype_dim==3){ + uspex_gui.calc._nlattice_line=3; + uspex_gui.calc._nlattice_vals=3; + }else{ + uspex_gui.calc._nlattice_line=2; + uspex_gui.calc._nlattice_vals=2; + } + if(uspex_gui.calc.Latticevalues!=NULL) g_free(uspex_gui.calc.Latticevalues); +uspex_gui.calc.Latticevalues=g_malloc((uspex_gui.calc._nlattice_line*uspex_gui.calc._nlattice_vals)*sizeof(gdouble)); + for(idx=0;idx1) { + GUI_COMBOBOX_SET(uspex_gui._latticeformat,1);/*lattice*/ + return; + } + switch(uspex_gui.calc._nlattice_vals){ + case 3: + if(uspex_gui.calc._calctype_dim==-2) + GUI_COMBOBOX_SET(uspex_gui._latticeformat,2);/*crystal*/ + else GUI_COMBOBOX_SET(uspex_gui._latticeformat,0);/*volume*/ + return; + case 6: + if((uspex_gui.calc._calctype_dim==-2)||(uspex_gui.calc._calctype_dim==3)) + GUI_COMBOBOX_SET(uspex_gui._latticeformat,2);/*crystal*/ + else GUI_COMBOBOX_SET(uspex_gui._latticeformat,0);/*volume*/ + return; + default: + GUI_COMBOBOX_SET(uspex_gui._latticeformat,0);/*Volume by default*/ + } } /***********************************/ /* Toggle spacegroup determination */ @@ -2803,6 +2845,7 @@ void uspex_gui_sync(){ g_free(text); GUI_COMBOBOX_GET_TEXT(uspex_gui.numSpecies,text); } + g_free(text); GUI_COMBOBOX_SET(uspex_gui.numSpecies,index);/*PULL index*/ /*now get valences from atomType*/ GUI_COMBOBOX_GET(uspex_gui.atomType,index);/*PUSH index*/ @@ -2869,7 +2912,37 @@ void uspex_gui_sync(){ } g_free(text); USPEX_REG_VAL(ExternalPressure,"%lf"); - /*goodBonds is special*/ +if(!uspex_gui.auto_bonds){ + GUI_COMBOBOX_GET(uspex_gui.goodBonds,index);/*PUSH index*/ + GUI_COMBOBOX_SET(uspex_gui.goodBonds,0); + GUI_COMBOBOX_GET_TEXT(uspex_gui.goodBonds,text); + if((g_ascii_strcasecmp(text,"ADD GOODBOND") != 0)){ + /*there is something to update*/ + if(uspex_gui.calc.goodBonds!=NULL) g_free(uspex_gui.calc.goodBonds); + uspex_gui.calc.goodBonds=g_malloc(uspex_gui.calc._nspecies*uspex_gui.calc._nspecies*sizeof(gdouble)); + ptr=text;jdx=0; + while((jdx Date: Wed, 21 Nov 2018 11:40:14 +0900 Subject: [PATCH 51/56] gui_uspex: fix IonDistances. --- src/file_uspex.c | 4 +- src/gui_uspex.c | 131 ++++++++++++++++++++--------------------------- src/gui_uspex.h | 2 - 3 files changed, 58 insertions(+), 79 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 3aa859f..0453485 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -1932,13 +1932,13 @@ is_w=0; if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; - line=g_strdup_printf("* CONSTRAINTS *"); + line=g_strdup_printf("* CONSTRAINTS *"); __TITLE(line); g_free(line); if(_UC.minVectorLength!=0.) __OUT_DOUBLE(minVectorLength); if(_UC.IonDistances!=NULL){ /*do not print IonDistances if all of them are zero*/ - zero_check=FALSE;for(i=0;i<_UC._nspecies;i++) zero_check|=(_UC.IonDistances[i]!=0.0); + zero_check=FALSE;for(i=0;i<(_UC._nspecies*_UC._nspecies);i++) zero_check|=(_UC.IonDistances[i]!=0.0); if(zero_check && (_UC.IonDistances!=NULL)) __OUT_TMAT_DOUBLE(IonDistances,"EndDistances",_UC._nspecies); } if(!_UC.constraint_enhancement) __OUT_BOOL(constraint_enhancement); diff --git a/src/gui_uspex.c b/src/gui_uspex.c index d3ace6f..25a8903 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -1611,60 +1611,35 @@ void opt_toggle(){ /**************************************/ void apply_distances(void){ gint index; - gchar *ptr,*ptr2; - gint i; - gint ndistval; - gdouble *distval=NULL; - gdouble *tmp=NULL; - gdouble dist; + gchar *text; + gchar *ptr; + gchar *ptr2; + gint idx; /**/ GUI_COMBOBOX_GET(uspex_gui.IonDistances,index); - GUI_ENTRY_GET_TEXT(uspex_gui._distances,uspex_gui._tmp_distances); - /*get the number of distance values*/ - ptr=&(uspex_gui._tmp_distances[0]); - while(*ptr==' ') ptr++;/*skip leading white space, if any*/ - ptr2=ptr;ndistval=0; - do{ - dist=g_ascii_strtod(ptr,&ptr2); + GUI_ENTRY_GET_TEXT(uspex_gui._distances,text); + /*there is _nspecies values per line (and _nspecies lines)*/ + ptr=&(text[0]); + while((*ptr!='\0')&&(!g_ascii_isgraph(*ptr))) ptr++; + ptr2=ptr;idx=0; + while(*ptr!='\0'){ + uspex_gui.calc.IonDistances[index*(uspex_gui.calc._nspecies)+idx]=g_ascii_strtod(ptr,&ptr2); if(ptr2==ptr) break; - ndistval++; - /*update array*/ - tmp = g_malloc(ndistval*sizeof(gdouble)); - if(distval){ - for(i=0;i=uspex_gui.calc._nspecies){ - /*use only nspecies values*/ - ptr2=g_strdup_printf("%4f",distval[0]); - ptr=ptr2; - for(i=1;i=uspex_gui.calc._nspecies) break; + } + /*now refresch IonDistances line*/ + text=g_strdup_printf("%.4lf",uspex_gui.calc.IonDistances[0]); + for(idx=1;idx=uspex_gui.calc._nmolecules){ /*use only nmolecules values*/ - ptr2=g_strdup_printf("%4f",molval[0]); + ptr2=g_strdup_printf("%.4lf",molval[0]); ptr=ptr2; for(i=1;i0){ - text=g_strdup_printf("%4f",uspex_gui.calc.Latticevalues[0]); + text=g_strdup_printf("%.4lf",uspex_gui.calc.Latticevalues[0]); for(idx=0;idx Date: Wed, 21 Nov 2018 16:59:54 +0900 Subject: [PATCH 52/56] gui_uspex: improve molecular calculation settings. --- src/gui_uspex.c | 373 +++++++++++++++++++++++++++++------------------- src/gui_uspex.h | 21 ++- 2 files changed, 241 insertions(+), 153 deletions(-) diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 25a8903..a3819d7 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -127,6 +127,15 @@ void gui_uspex_init(struct model_pak *model){ for(idx=0;idx=uspex_gui.calc._nspecies) break; } /*now refresch IonDistances line*/ - text=g_strdup_printf("%.4lf",uspex_gui.calc.IonDistances[0]); + text=g_strdup_printf("%.4lf",uspex_gui.calc.IonDistances[index*(uspex_gui.calc._nspecies)]); for(idx=1;idx=uspex_gui.calc._nmolecules){ - /*use only nmolecules values*/ - ptr2=g_strdup_printf("%.4lf",molval[0]); - ptr=ptr2; - for(i=1;i=uspex_gui.calc._nmolecules) break; + } + /*now refresh MolCenters line*/ + text=g_strdup_printf("%.4lf",uspex_gui.calc.MolCenters[index*(uspex_gui.calc._nmolecules)]); + for(idx=1;idxdata; + /*to be registered, a model must have a molecule*/ + if(g_slist_length(data->moles)>0) { + text=g_strdup_printf("%i: %s",index,data->basename); + GUI_COMBOBOX_ADD(uspex_gui.mol_gdis,text); + g_free(text); + } + index++; + } + GUI_COMBOBOX_SET(uspex_gui.mol_gdis,uspex_gui._tmp_mols_gdis[0]); } /**************************/ /* select Molecular model */ @@ -2678,26 +2657,121 @@ void uspex_mol_model_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch (index){ - case 1: - GUI_UNLOCK(uspex_gui.mol_model_button); + case 1:/*from folder*/ GUI_UNLOCK(uspex_gui.num_mol); + GUI_UNLOCK(uspex_gui.mol_model_button); + GUI_LOCK(uspex_gui.mol_gdis); + GUI_LOCK(uspex_gui.curr_mol); + GUI_LOCK(uspex_gui.mol_gulp); + GUI_LOCK(uspex_gui.mol_apply_button); break; - case 2: + case 2:/*from gdis*/ + GUI_UNLOCK(uspex_gui.num_mol); GUI_LOCK(uspex_gui.mol_model_button); - GUI_LOCK(uspex_gui.num_mol); + GUI_UNLOCK(uspex_gui.mol_gdis); + GUI_UNLOCK(uspex_gui.curr_mol); + GUI_UNLOCK(uspex_gui.mol_gulp); + GUI_UNLOCK(uspex_gui.mol_apply_button); break; - case 0: + case 0:/*already provided*/ /* fall through */ default: - GUI_UNLOCK(uspex_gui.mol_model_button); GUI_LOCK(uspex_gui.num_mol); + GUI_LOCK(uspex_gui.mol_model_button); + GUI_LOCK(uspex_gui.mol_gdis); + GUI_LOCK(uspex_gui.curr_mol); + GUI_LOCK(uspex_gui.mol_gulp); + GUI_LOCK(uspex_gui.mol_apply_button); } } /*******************************/ /* load molecular model/folder */ /*******************************/ -void load_mod_model_file(void){ +void load_mol_model_folder(void){ + GUI_OBJ *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_FOLDER(uspex_gui.window,file_chooser,"Select MOL_x folder"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + /*save that path as mol_model #1*/ + GUI_COMBOBOX_ADD_TEXT(uspex_gui.mol_model,1,text); + GUI_COMBOBOX_DEL(uspex_gui.mol_model,2); + GUI_COMBOBOX_SET(uspex_gui.mol_model,1); + g_free(text); + g_free(filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); +} +/******************************/ +/* update number of molecules */ +/******************************/ +void spin_update_num_mol(void){ + gint idx; + gint i=uspex_gui._tmp_num_mol; + gint *tmp_i; + gboolean *tmp_b; + /**/ + tmp_i=g_malloc(i*sizeof(gint)); + tmp_b=g_malloc(i*sizeof(gboolean)); + if(i Date: Wed, 21 Nov 2018 20:56:47 +0900 Subject: [PATCH 53/56] gui_uspex: gui_sync 3/3 + fixes. --- src/file_uspex.c | 33 +++-- src/gui_uspex.c | 359 ++++++++++++++++++++++++++++++++++++++--------- src/gui_uspex.h | 8 +- 3 files changed, 317 insertions(+), 83 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index 0453485..d9c12e3 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -125,6 +125,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC._nlattice_line=0; _UC._nlattice_vals=0; _UC.Latticevalues=NULL; + _UC._nsplits=0; _UC.splitInto=NULL; _UC.pickUpYN=FALSE; _UC.pickUpGen=0; @@ -173,6 +174,7 @@ void init_uspex_parameters(uspex_calc_struct *uspex_calc){ _UC.thicknessS=2.0; _UC.thicknessB=3.0; _UC.reconstruct=1; + _UC.StoichiometryStart=NULL;/*almost undocumented*/ _UC.firstGeneMax=11; _UC.minAt=0; _UC.maxAt=0; @@ -1025,14 +1027,6 @@ while((*ptr!='\n')&&(*ptr!='\0')){ ptr=ptr2+1; i++; } -/* - while((*ptr!='\n')&&(*ptr!='\0')){ - __SKIP_BLANK(ptr); - _UC.abinitioCode[i]=(gint)g_ascii_strtoull(ptr,&ptr2,10); - ptr=ptr2+1; - i++; - } -*/ g_free(line); line = file_read_line(vf);/*this is the ENDabinit line*/ g_free(line); @@ -1220,6 +1214,23 @@ while((*ptr!='\n')&&(*ptr!='\0')){ __GET_DOUBLE(thicknessS); __GET_DOUBLE(thicknessB); __GET_INT(reconstruct); + if (find_in_string("StoichiometryStart",line) != NULL) { + g_free(line);line = file_read_line(vf);/*go next line*/ + _UC.StoichiometryStart=g_malloc(_UC._nspecies*sizeof(gint)); + for(i=0;i<_UC._nspecies;i++) _UC.StoichiometryStart[i]=0; + ptr=&(line[0]);i=0; + while((*ptr!='\n')&&(*ptr!='\0')){ + __SKIP_BLANK(ptr); + _UC.StoichiometryStart[i]=(gint)g_ascii_strtoull(ptr,&ptr2,10); + ptr=ptr2+1; + i++; + } + g_free(line); + line = file_read_line(vf);/*this is the endStoichiometryStart line*/ + g_free(line); + line = file_read_line(vf); + continue; + } __GET_INT(firstGeneMax); __GET_INT(minAt); __GET_INT(maxAt); @@ -1579,6 +1590,7 @@ if(_SRC._nlattice_line==0){ _CP(thicknessS); _CP(thicknessB); _CP(reconstruct); + _COPY(StoichiometryStart,_SRC._nspecies,gint); _CP(firstGeneMax); _CP(minAt); _CP(maxAt); @@ -1959,7 +1971,7 @@ if((_UC.calculationMethod != US_CM_VCNEB)&&(_UC.calculationMethod != US_CM_TPS)) else __OUT_BK_DOUBLE(Latticevalues,"Endvalues",_UC._nlattice_vals); } } - if(_UC.splitInto!=NULL) __OUT_BK_INT(splitInto,"EndSplitInto",_UC._nsplits); + if((_UC._nsplits>1)&&(_UC.splitInto!=NULL)) __OUT_BK_INT(splitInto,"EndSplitInto",_UC._nsplits); }/*VCNEB,TPS don't require CELL information*/ if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ @@ -2104,6 +2116,7 @@ is_w=0; if(_UC.thicknessS!=2.0) __OUT_DOUBLE(thicknessS); if(_UC.thicknessB!=3.0) __OUT_DOUBLE(thicknessB); if(_UC.reconstruct!=1) __OUT_INT(reconstruct); + if(_UC.StoichiometryStart!=NULL) __OUT_BK_INT(StoichiometryStart,"endStoichiometryStart",_UC._nspecies); if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; @@ -2143,6 +2156,7 @@ is_w=0; line=g_strdup_printf("* VARIABLE-CELL NEB (VCNEB) *"); __TITLE(line); g_free(line); +if(_UC.calculationMethod==US_CM_VCNEB){ if(_UC.vcnebType!=110) __OUT_INT(vcnebType); if(_UC.numImages!=9) __OUT_INT(numImages); if(_UC.numSteps!=200) __OUT_INT(numSteps); @@ -2162,6 +2176,7 @@ is_w=0; if(_UC.pickupImages!=NULL) __OUT_BK_INT(pickupImages,"EndPickupImages",_UC._npickimg); if(_UC.FormatType!=2) __OUT_INT(FormatType); if(_UC.PrintStep!=1) __OUT_INT(PrintStep); +} if(is_w==0) fseek(vf,vfpos,SEEK_SET);/* rewind to flag */ else vfpos=ftell(vf);/* flag */ is_w=0; diff --git a/src/gui_uspex.c b/src/gui_uspex.c index a3819d7..6897732 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -67,14 +67,7 @@ void gui_uspex_init(struct model_pak *model){ /*prepare local values*/ uspex_gui._tmp_atom_typ=0;uspex_gui._tmp_atom_num=0;uspex_gui._tmp_atom_val=0; strcpy(uspex_gui._tmp_atom_sym,elements[uspex_gui._tmp_atom_typ].symbol); - uspex_gui._tmp_specificTrans=NULL; if(uspex_gui.calc._nspecies<1) uspex_gui.calc._nspecies=1; - if(uspex_gui.calc._nspetrans>0) { - line=g_strdup(""); - for(idx=0;idx2 - specific supercomputer."); GUI_CHECK_TABLE(table,button,uspex_gui.calc.PhaseDiagram,NULL,"PhaseDiag",3,4,7,8);/*not calling anything*/ GUI_TOOLTIP(button,"PhaseDiagram: Ch. 4.8 DEFAULT: FALSE\nSet calculation of an estimated phase diagram\nfor calculationMethod 30X (300, 301, s300, and s301)."); /* line 8 */ @@ -3724,8 +3902,9 @@ GUI_TOOLTIP(button,"PhaseDiagram: Ch. 4.8 DEFAULT: FALSE\nSet calculation of an GUI_TOOLTIP(uspex_gui.job_path,"Select USPEX calculation folder.\nThis folder is where run_uspex will be launched\nand result will be read by GDIS."); GUI_OPEN_BUTTON_TABLE(table,button,uspex_path_dialog,1,2,8,9); GUI_TEXT_TABLE(table,uspex_gui.remoteFolder,uspex_gui.calc.remoteFolder,"Remote:",2,3,8,9); -GUI_TOOLTIP(uspex_gui.remoteFolder,"remoteFolder: Ch. 4.8 DEFAULT: none\nExecution folder on the distant computer."); +GUI_TOOLTIP(uspex_gui.remoteFolder,"remoteFolder: Ch. 4.8 DEFAULT: none\nWhen using remote submission, this hold the\nexecution folder on the distant computer."); GUI_OPEN_BUTTON_TABLE(table,button,load_remote_folder,3,4,8,9); + /*TODO: disable remote when whichCluster<2*/ /* --- Restart */ GUI_LABEL_TABLE(table,"Restart",0,4,9,10); /* line 10 */ @@ -3734,7 +3913,7 @@ GUI_TOOLTIP(uspex_gui.pickUpYN,"pickUpYN: deprecated DEFAULT: 0\nSet to restart GUI_ENTRY_TABLE(table,uspex_gui.pickUpGen,uspex_gui.calc.pickUpGen,"%i","GEN:",1,2,10,11); GUI_TOOLTIP(uspex_gui.pickUpGen,"pickUpGen: Ch. 4.7 DEFAULT: 0\nSelect the generation at which USPEX should restart.\nA new calculation is started for 0 (default)."); GUI_ENTRY_TABLE(table,uspex_gui.pickUpFolder,uspex_gui.calc.pickUpFolder,"%i","Folder:",2,3,10,11); -GUI_TOOLTIP(uspex_gui.pickUpGen,"pickUpFolder: Ch. 4.7 DEFAULT: 0\nSelect the folder number from which to restart from.\nSetting N means restarting from a folder named \"resultN\"."); +GUI_TOOLTIP(uspex_gui.pickUpFolder,"pickUpFolder: Ch. 4.7 DEFAULT: 0\nSelect the folder number from which to restart from.\nSetting N means restarting from a folder named \"resultN\"."); GUI_CHECK_TABLE(table,button,uspex_gui.restart_cleanup,NULL,"CLEANUP",3,4,10,11);/*not calling anything*/ GUI_TOOLTIP(button,"Cleanup the calculation directory before restart,\nie. remove still_running, NOT_YET, 0PhaseDiagram: Ch. 4.8 DEFAULT: FALSE\nSet calculation of an estimated phase diagram\nfor calculationMethod 30X (300, 301, s300, and s301)."); /* reserved for future use */ @@ -3765,7 +3944,18 @@ GUI_TOOLTIP(button,"collectForces: Ch. 4.12 DEFAULT: FALSE\nCollect relaxation i GUI_TOOLTIP(button,"ordering_active: Ch. 4.12 DEFAULT: TRUE\nSwitch the \"biasing of variation operators by local order parameters\"."); GUI_CHECK_TABLE(table,button,uspex_gui.calc.symmetrize,NULL,"symmetrize",1,2,3,4);/*not calling anything*/ GUI_TOOLTIP(button,"symmetrize: Ch. 4.13 DEFAULT: FALSE\nTransform all structure to \"standard symmetry-adapted crystallografic setting\"."); - GUI_TEXT_TABLE(table,uspex_gui.valenceElectr,uspex_gui._tmp_valence_e,"VALENCE:",2,4,3,4); + if(uspex_gui.calc.valenceElectr==NULL){ + title=g_strdup(""); + }else{ + title=g_strdup_printf("%i",uspex_gui.calc.valenceElectr[0]); + for(idx=1;idxB):",0,1,13,14); @@ -3966,7 +4167,18 @@ GUI_TOOLTIP(uspex_gui.Kconstant,"Kconstant: Ch. 6.1 DEFAULT: 5\nFixed spring con GUI_TOOLTIP(uspex_gui.optMethodCIDI,"optMethodCIDI: Ch. 6.1 DEFAULT: 0\nOption for Climbing-Image (CI) and Descending-Image (DI)."); GUI_ENTRY_TABLE(table,uspex_gui.startCIDIStep,uspex_gui.calc.startCIDIStep,"%i","Start CI/DI:",1,2,10,11); GUI_TOOLTIP(uspex_gui.startCIDIStep,"startCIDIStep: Ch. 6.1 DEFAULT: 100\nStarting step for CI/DI method."); - GUI_TEXT_TABLE(table,uspex_gui.pickupImages,uspex_gui._tmp_pickupImages,"Pickup:",2,3,10,11); + if(uspex_gui.calc._npickimg<1){ + title=g_strdup(""); + }else{ + title=g_strdup_printf("%i",uspex_gui.calc.pickupImages[0]); + } + for(idx=1;idx Date: Thu, 22 Nov 2018 02:17:57 +0900 Subject: [PATCH 54/56] gui_uspex: fix calculation steps 1/2. --- src/file_uspex.c | 42 ++++++++++++++++--------- src/gui_uspex.c | 82 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 82 insertions(+), 42 deletions(-) diff --git a/src/file_uspex.c b/src/file_uspex.c index d9c12e3..7eb1829 100644 --- a/src/file_uspex.c +++ b/src/file_uspex.c @@ -1013,12 +1013,13 @@ else n_size=_UC._nspecies; /*TODO: deal with META parenthesis here!*/ _UC._isfixed = g_malloc(_UC._num_opt_steps*sizeof(gboolean)); for(i=0;i<_UC._num_opt_steps;i++) _UC._isfixed[i]=TRUE; -i=0;n_size=0; +j=0;i=0;n_size=0; while((*ptr!='\n')&&(*ptr!='\0')){ __SKIP_BLANK(ptr); if(*ptr=='(') { n_size=1; ptr++; + j++; } if(n_size==0) _UC._isfixed[i]=TRUE; else _UC._isfixed[i]=FALSE; @@ -1027,6 +1028,8 @@ while((*ptr!='\n')&&(*ptr!='\0')){ ptr=ptr2+1; i++; } +/*funny thing: if they are all true means they are all false*/ +if(j==0) for(i=0;i<_UC._num_opt_steps;i++) _UC._isfixed[i]=FALSE; g_free(line); line = file_read_line(vf);/*this is the ENDabinit line*/ g_free(line); @@ -1990,21 +1993,30 @@ is_w=0; g_free(line); if(_UC.abinitioCode!=NULL) { /*NEW: deals with parenthesis*/ - fprintf(vf,"%% abinitioCode\n"); - if(!_UC._isfixed[0]) fprintf(vf,"(%i",_UC.abinitioCode[0]);/*possible?*/ - else fprintf(vf,"%i",_UC.abinitioCode[0]); - for(i=1;i<(_UC._num_opt_steps);i++) { - if(_UC._isfixed[i]!=_UC._isfixed[i-1]) { - if(!_UC._isfixed[i]) fprintf(vf," (%i",_UC.abinitioCode[i]);/*has become not fixed*/ - else fprintf(vf,") %i",_UC.abinitioCode[i]);/*has become fixed (possible?)*/ - }else{ - fprintf(vf," %i",_UC.abinitioCode[i]);/*same as previous*/ +/*if they are all false means the are all true*/ +zero_check=FALSE;for(i=0;i<_UC._num_opt_steps;i++) zero_check|=_UC._isfixed[i]; +if(!zero_check) + for(i=0;i<_UC._num_opt_steps;i++) + _UC._isfixed[i]=TRUE; + fprintf(vf,"%% abinitioCode\n"); + if(!_UC._isfixed[0]) fprintf(vf,"(%i",_UC.abinitioCode[0]);/*possible?*/ + else fprintf(vf,"%i",_UC.abinitioCode[0]); + for(i=1;i<(_UC._num_opt_steps);i++) { + if(_UC._isfixed[i]!=_UC._isfixed[i-1]) { + if(!_UC._isfixed[i]) fprintf(vf," (%i",_UC.abinitioCode[i]);/*has become not fixed*/ + else fprintf(vf,") %i",_UC.abinitioCode[i]);/*has become fixed (possible?)*/ + }else{ + fprintf(vf," %i",_UC.abinitioCode[i]);/*same as previous*/ + } } - } - if(_UC._isfixed[_UC._num_opt_steps-1]) fprintf(vf,"\n");/*terminate on fixed ie. normal*/ - else fprintf(vf,")\n");/*terminate on non fixed*/ - fprintf(vf,"%% ENDabinit\n"); - is_w++; + if(_UC._isfixed[_UC._num_opt_steps-1]) fprintf(vf,"\n");/*terminate on fixed ie. normal*/ + else fprintf(vf,")\n");/*terminate on non fixed*/ + fprintf(vf,"%% ENDabinit\n"); +/*restore previous values*/ +if(!zero_check) + for(i=0;i<_UC._num_opt_steps;i++) + _UC._isfixed[i]=FALSE; + is_w++; //__OUT_BK_INT(abinitioCode,"ENDabinit",_UC._num_opt_steps); } /*do not print KresolStart if linearly = {0.2~0.08}*/ diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 6897732..8ea483b 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -73,7 +73,7 @@ void gui_uspex_init(struct model_pak *model){ uspex_gui._tmp_curr_step=1.; if(uspex_gui.calc._isfixed==NULL) { uspex_gui.calc._isfixed=g_malloc(uspex_gui.calc._num_opt_steps*sizeof(gboolean)); - for(idx=0;idxuspex_gui.calc._num_opt_steps){ + /*increase*/ + for(idx=0;idxi) uspex_gui._tmp_curr_step=i; } /***************************/ /* change the current step */ @@ -2002,7 +2038,6 @@ void spin_update_curr_step(void){ gchar *text; gchar *ptr; /*update step information*/ - uspex_gui._tmp_isfixed=uspex_gui.calc._isfixed[i-1]; GUI_COMBOBOX_SET(uspex_gui.abinitioCode,uspex_gui.calc.abinitioCode[i-1]); text=g_strdup_printf("%.4lf",uspex_gui.calc.KresolStart[i-1]); @@ -2011,7 +2046,7 @@ void spin_update_curr_step(void){ text=g_strdup_printf("%.4lf",uspex_gui.calc.vacuumSize[i-1]); GUI_ENTRY_TEXT(uspex_gui.vacuumSize,text); g_free(text); - + /**/ if(uspex_gui.calc._isCmdList){ /*we have 1 cmd per step*/ text=g_strdup(uspex_gui.calc.commandExecutable); @@ -2021,7 +2056,6 @@ void spin_update_curr_step(void){ text++; } if(*text=='\0') { - g_free(text); text=g_strdup("N/A"); GUI_ENTRY_TEXT(uspex_gui.commandExecutable,text); g_free(text); @@ -2032,7 +2066,6 @@ void spin_update_curr_step(void){ GUI_ENTRY_TEXT(uspex_gui.commandExecutable,text); } } - } /********************/ /* toggle auto_step */ @@ -2057,14 +2090,6 @@ void toggle_auto_step(void){ } } /********************************/ -/* toggle full/fixed relaxation */ -/********************************/ -void toggle_isfixed(void){ - /*nothing for now*/ - gint i=(gint)uspex_gui._tmp_curr_step; - uspex_gui.calc._isfixed[i-1]=uspex_gui._tmp_isfixed; -} -/********************************/ /* select AI code for this step */ /********************************/ void uspex_ai_selected(GUI_OBJ *w){ @@ -2093,7 +2118,7 @@ void load_abinito_exe_dialog(void){ /* generate input/optional file for this step */ /**********************************************/ void generate_step(void){ - + /*THIS IS A TODO*/ } /**************************/ /* Apply step information */ @@ -2115,13 +2140,14 @@ void apply_step(void){ ptr=uspex_gui.calc.commandExecutable; index=1; while((index Date: Thu, 22 Nov 2018 18:40:51 +0900 Subject: [PATCH 55/56] gui_uspex: fix calculation steps 1/2 + model integration with GDIS. --- src/gui_uspex.c | 650 ++++++++++++++++++++++++++++++++++++------------ src/gui_uspex.h | 7 +- 2 files changed, 494 insertions(+), 163 deletions(-) diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 8ea483b..0318557 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -63,6 +63,7 @@ struct uspex_calc_gui uspex_gui; void gui_uspex_init(struct model_pak *model){ gint idx; gchar *line; + gchar *ptr; uspex_gui.cur_page=USPEX_PAGE_SYSTEM; /*prepare local values*/ uspex_gui._tmp_atom_typ=0;uspex_gui._tmp_atom_num=0;uspex_gui._tmp_atom_val=0; @@ -255,14 +256,37 @@ void gui_uspex_init(struct model_pak *model){ uspex_gui.calc.vacuumSize=g_malloc(uspex_gui.calc._num_opt_steps*sizeof(gdouble)); for(idx=0;idxuspex_gui.calc._num_opt_steps){ /*increase*/ for(idx=0;idxi) uspex_gui._tmp_curr_step=i; + if(uspex_gui._tmp_curr_step>i) uspex_gui._tmp_curr_step=(gdouble)i; + GUI_SPIN_SET(uspex_gui._curr_step,uspex_gui._tmp_curr_step); } /***************************/ /* change the current step */ /***************************/ void spin_update_curr_step(void){ gint i=(gint)uspex_gui._tmp_curr_step; - gint index; gchar *text; - gchar *ptr; /*update step information*/ uspex_gui._tmp_isfixed=uspex_gui.calc._isfixed[i-1]; + if(uspex_gui._tmp_isfixed) GUI_TOGGLE_ON(uspex_gui._isfixed); + else GUI_TOGGLE_OFF(uspex_gui._isfixed); GUI_COMBOBOX_SET(uspex_gui.abinitioCode,uspex_gui.calc.abinitioCode[i-1]); text=g_strdup_printf("%.4lf",uspex_gui.calc.KresolStart[i-1]); GUI_ENTRY_TEXT(uspex_gui.KresolStart,text); @@ -2046,26 +2142,29 @@ void spin_update_curr_step(void){ text=g_strdup_printf("%.4lf",uspex_gui.calc.vacuumSize[i-1]); GUI_ENTRY_TEXT(uspex_gui.vacuumSize,text); g_free(text); - /**/ - if(uspex_gui.calc._isCmdList){ - /*we have 1 cmd per step*/ - text=g_strdup(uspex_gui.calc.commandExecutable); - index=1; - while((indexdata; + /*to be registered a model must have at least 1 atom*/ + if(g_slist_length(data->cores)>0) { + text=g_strdup_printf("%i: %s",index,data->basename); + GUI_COMBOBOX_ADD(uspex_gui.meta_model,text); + g_free(text); + } + index++; + } + GUI_COMBOBOX_SET(uspex_gui.meta_model,0); +} /****************************************/ /* load metadynamics starting structure */ /****************************************/ void load_meta_start_file(void){ - + GUI_OBJ *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(uspex_gui.window,file_chooser,"Select META starting point","POSCAR*","POSCAR_1"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_COMBOBOX_ADD_TEXT(uspex_gui.meta_model,0,text); + GUI_COMBOBOX_DEL(uspex_gui.meta_model,1); + GUI_COMBOBOX_SET(uspex_gui.meta_model,0); + g_free(text); + g_free (filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } /*****************************/ /* select metadynamics model */ @@ -2513,13 +2768,11 @@ void uspex_meta_model_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch (index){ - case 1: - GUI_LOCK(uspex_gui.meta_model_button); - break; case 0: - /* fall through */ - default: GUI_UNLOCK(uspex_gui.meta_model_button); + break; + default: + GUI_LOCK(uspex_gui.meta_model_button); } } /*********************/ @@ -2668,6 +2921,30 @@ void uspex_FormatType_selected(GUI_OBJ *w){ uspex_gui.calc.FormatType=2; } } +/*************************************/ +/* initialize image models from GDIS */ +/*************************************/ +void init_img_gdis_model(void){ + gint index; + gchar *text; + GSList *list; + struct model_pak *data; + /*WIPE MODEL*/ + GUI_COMBOBOX_WIPE(uspex_gui.img_model); + GUI_COMBOBOX_ADD(uspex_gui.img_model,"From VASP5 POSCAR file"); + index=1; + for(list=sysenv.mal;list;list=g_slist_next(list)){ + data = list->data; + /*to be registered, a model must 3D periodic... I think*/ + if(data->periodic==3){ + text=g_strdup_printf("%i: %s",index,data->basename); + GUI_COMBOBOX_ADD(uspex_gui.img_model,text); + g_free(text); + } + index++; + } + GUI_COMBOBOX_SET(uspex_gui.img_model,0); +} /*****************************/ /* select VCNEB Images model */ /*****************************/ @@ -2675,20 +2952,36 @@ void uspex_img_model_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch (index){ - case 1: - GUI_LOCK(uspex_gui.img_model_button); - break; case 0: - /* fall through */ - default: GUI_UNLOCK(uspex_gui.img_model_button); + break; + default: + GUI_LOCK(uspex_gui.img_model_button); } } /*************************/ /* load VCNEB Image file */ /*************************/ void load_img_model_file(void){ - + GUI_OBJ *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(uspex_gui.window,file_chooser,"Select VCNEB image model","*","VASP5 format"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_COMBOBOX_ADD_TEXT(uspex_gui.img_model,0,text); + GUI_COMBOBOX_DEL(uspex_gui.img_model,1); + GUI_COMBOBOX_SET(uspex_gui.img_model,0); + g_free(text); + g_free (filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } /*****************************************/ /* initialize molecular models from GDIS */ @@ -2812,7 +3105,7 @@ void spin_update_num_mol(void){ /* Select a GDIS model */ /***********************/ void uspex_gdis_mol_selected(GUI_OBJ *w){ - + /*nothing here for now*/ } /***************************/ /* update current molecule */ @@ -2836,6 +3129,30 @@ void apply_gdis_mol(void){ uspex_gui._tmp_mols_gdis[i]=index; uspex_gui._tmp_mols_gulp[i]=uspex_gui.mol_as_gulp; } +/*****************************************/ +/* init substrate model from GDIS models */ +/*****************************************/ +void init_substrate_models(){ + gint index; + gchar *text; + GSList *list; + struct model_pak *data; + /*WIPE MODEL*/ + GUI_COMBOBOX_WIPE(uspex_gui.substrate_model); + GUI_COMBOBOX_ADD(uspex_gui.substrate_model,"From VASP5 POSCAR file"); + index=1; + for(list=sysenv.mal;list;list=g_slist_next(list)){ + data = list->data; + /*to be registered, a model must be 3D periodic*/ + if(data->periodic==3){ + text=g_strdup_printf("%i: %s",index,data->basename); + GUI_COMBOBOX_ADD(uspex_gui.substrate_model,text); + g_free(text); + } + index++; + } + GUI_COMBOBOX_SET(uspex_gui.substrate_model,0); +} /**********************************/ /* select surface substrate model */ /**********************************/ @@ -2843,22 +3160,37 @@ void uspex_substrate_model_selected(GUI_OBJ *w){ gint index; GUI_COMBOBOX_GET(w,index); switch (index){ - case 1: - GUI_LOCK(uspex_gui.substrate_model_button); - break; case 0: - /* fall through */ - default: GUI_UNLOCK(uspex_gui.substrate_model_button); + break; + default: + GUI_LOCK(uspex_gui.substrate_model_button); } } /********************************/ /* load surface substrate model */ /********************************/ void load_substrate_model_file(void){ - + GUI_OBJ *file_chooser; + gint have_answer; + gchar *filename; + gchar *text; + /**/ + GUI_PREPARE_OPEN_DIALOG(uspex_gui.window,file_chooser,"Select Substrate structure","POSCAR_SUBSTRATE","VASP5 format"); + GUI_OPEN_DIALOG_RUN(file_chooser,have_answer,filename); + if(have_answer){ + /*there should be no case where have_answer==TRUE AND filename==NULL, but just in case.*/ + if(filename) { + text=g_strdup_printf("%s",filename); + GUI_COMBOBOX_ADD_TEXT(uspex_gui.substrate_model,0,text); + GUI_COMBOBOX_DEL(uspex_gui.substrate_model,1); + GUI_COMBOBOX_SET(uspex_gui.substrate_model,0); + g_free(text); + g_free (filename); + } + } + GUI_KILL_OPEN_DIALOG(file_chooser); } - /************************/ /* Switch notebook page */ /************************/ @@ -3132,7 +3464,7 @@ if(uspex_gui.auto_C_lat){ //_isfixed is already sync USPEX_REG_VAL(numProcessors,"%i"); USPEX_REG_VAL(numParallelCalcs,"%i"); - //commandExecutable is already sync + register_commandExecutable(); USPEX_REG_VAL(whichCluster,"%i"); USPEX_REG_TEXT(remoteFolder); //PhaseDiagram is already sync @@ -3895,16 +4227,16 @@ GUI_TOOLTIP(uspex_gui.KresolStart,"KresolStart: Ch. 4.8 DEFAULT: 0.2-0.08\nRecip GUI_ENTRY_TABLE(table,uspex_gui.vacuumSize,uspex_gui.calc.vacuumSize[0],"%.4f","vacuum:",3,4,2,3); GUI_TOOLTIP(uspex_gui.vacuumSize,"vacuumSize: Ch. 4.8 DEFAULT: 10.0\nVacuum size (Ang.) between neighbor atoms from adjacent unit cells.\nFor cluster, 2D-crystal, and surfaces only."); /* line 3 */ - GUI_TEXT_TABLE(table,uspex_gui.ai_input,uspex_gui._tmp_ai_input,"INP:",0,1,3,4); + GUI_TEXT_TABLE(table,uspex_gui.ai_input,uspex_gui._tmp_ai_input[0],"INP:",0,1,3,4); GUI_TOOLTIP(uspex_gui.ai_input,"Input for the current calculation step.\nFile name as to end with *_N where N is the step number."); GUI_OPEN_BUTTON_TABLE(table,uspex_gui.ai_input_button,load_ai_input_dialog,1,2,3,4); - GUI_TEXT_TABLE(table,uspex_gui.ai_opt,uspex_gui._tmp_ai_opt,"OPT:",2,3,3,4); + GUI_TEXT_TABLE(table,uspex_gui.ai_opt,uspex_gui._tmp_ai_opt[0],"OPT:",2,3,3,4); GUI_TOOLTIP(uspex_gui.ai_opt,"Complementary (optional) file for the current calculation step.\nWhen present, file name as to end with *_N where N is the step number."); GUI_OPEN_BUTTON_TABLE(table,uspex_gui.ai_opt_button,load_ai_opt_dialog,3,4,3,4); /* line 4 */ - GUI_TEXT_TABLE(table,uspex_gui.commandExecutable,uspex_gui._tmp_commandExecutable,"EXE:",0,1,4,5); + GUI_TEXT_TABLE(table,uspex_gui.commandExecutable,uspex_gui._tmp_commandExecutable[0],"EXE:",0,1,4,5); GUI_TOOLTIP(uspex_gui.commandExecutable,"commandExecutable: Ch. 4.8 DEFAULT: none\nCurrent optimisation step executable of submission script."); - GUI_OPEN_BUTTON_TABLE(table,button,load_abinito_exe_dialog,1,2,4,5); + GUI_OPEN_BUTTON_TABLE(table,button,load_abinitio_exe_dialog,1,2,4,5); GUI_BUTTON_TABLE(table,uspex_gui.ai_generate,"Generate",generate_step,2,3,4,5); GUI_TOOLTIP(uspex_gui.ai_generate,"Use GDIS integrated interface to create this step input file.\nUnavailable (for now) m(_ _)m"); GUI_APPLY_BUTTON_TABLE(table,button,apply_step,3,4,4,5); @@ -4032,7 +4364,7 @@ GUI_TOOLTIP(uspex_gui.BoltzTraP_T_efcut,"BoltzTraP_T_efcut: Ch. 5.2 DEFAULT: 0.1 /* line 9 */ GUI_TEXT_TABLE(table,uspex_gui.cmd_BoltzTraP,uspex_gui._tmp_cmd_BoltzTraP,"cmd:",0,1,9,10); GUI_TOOLTIP(uspex_gui.cmd_BoltzTraP,"BoltzTraP software command/script (optional)."); -GUI_OPEN_BUTTON_TABLE(table,button,load_cmd_BoltzTraP,1,2,9,10); +GUI_OPEN_BUTTON_TABLE(table,uspex_gui.cmd_BoltzTraP_button,load_cmd_BoltzTraP,1,2,9,10); GUI_ENTRY_TABLE(table,uspex_gui.TE_T_interest,uspex_gui.calc.TE_T_interest,"%.4f","T_target:",2,3,9,10); GUI_TOOLTIP(uspex_gui.TE_T_interest,"TE_T_interest: Ch. 5.2 DEFAULT: 300.0Y\nTarget temperature to optimize thermoelectric efficiency."); GUI_ENTRY_TABLE(table,uspex_gui.TE_threshold,uspex_gui.calc.TE_threshold,"%.4f","Threshold:",3,4,9,10); @@ -4219,8 +4551,6 @@ GUI_TOOLTIP(uspex_gui.PrintStep,"PrintStep: Ch. 6.1 DEFAULT: 1\nSave restart fil GUI_COMBOBOX_ADD(uspex_gui.FormatType,"3 - XYZ format with lattice."); GUI_TOOLTIP(uspex_gui.FormatType,"FormatType: Ch. 6.1 DEFAULT: 2\nFormat of structures in PATH output directory."); GUI_COMBOBOX_TABLE(table,uspex_gui.img_model,"Model:",1,3,11,12); - GUI_COMBOBOX_ADD(uspex_gui.img_model,"From Images file"); - GUI_COMBOBOX_ADD(uspex_gui.img_model,"UNDER CONSTRUCTION"); GUI_TOOLTIP(uspex_gui.img_model,"Select the original Images model."); GUI_OPEN_BUTTON_TABLE(table,uspex_gui.img_model_button,load_img_model_file,3,4,11,12); /* --- Molecules */ @@ -4248,8 +4578,6 @@ GUI_TOOLTIP(uspex_gui.optFreezing,"Use GULP chemical labels and charge Zmatrix f GUI_LABEL_TABLE(table,"Surfaces",0,4,15,16); /* line 16 */ GUI_COMBOBOX_TABLE(table,uspex_gui.substrate_model,"MODEL:",0,2,16,17); - GUI_COMBOBOX_ADD(uspex_gui.substrate_model,"From VASP5 POSCAR file"); - GUI_COMBOBOX_ADD(uspex_gui.substrate_model,"UNDER CONSTRUCTION"); GUI_TOOLTIP(uspex_gui.substrate_model,"Select the model to use as a substrate\nie. without buffer, surface, and vacuum region."); GUI_OPEN_BUTTON_TABLE(table,uspex_gui.substrate_model_button,load_substrate_model_file,2,3,16,17); GUI_ENTRY_TABLE(table,uspex_gui.thicknessS,uspex_gui.calc.thicknessS,"%.4f","S_thick:",3,4,16,17); @@ -4317,6 +4645,7 @@ GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (A GUI_COMBOBOX_SETUP(uspex_gui.TE_goal,0,uspex_TE_goal_selected); GUI_COMBOBOX_SETUP(uspex_gui.FullRelax,2,uspex_relax_selected); GUI_COMBOBOX_SETUP(uspex_gui.meta_model,0,uspex_meta_model_selected); + init_metadynamics_models(); GUI_COMBOBOX_SETUP(uspex_gui._vcnebtype_method,0,uspex_vcneb_method_selected); GUI_COMBOBOX_SETUP(uspex_gui.optReadImages,2,uspex_ReadImg_selected); GUI_COMBOBOX_SETUP(uspex_gui.optimizerType,0,uspex_optimizerType_selected); @@ -4325,12 +4654,13 @@ GUI_TOOLTIP(uspex_gui.thicknessB,"thicknessB: Ch. 5.3 DEFAULT: 3.0\nThickness (A GUI_COMBOBOX_SETUP(uspex_gui.FormatType,0,uspex_FormatType_selected); uspex_CIDI_selected(uspex_gui.optMethodCIDI); GUI_COMBOBOX_SETUP(uspex_gui.img_model,0,uspex_img_model_selected); + init_img_gdis_model(); update_vcnebType(); GUI_COMBOBOX_SETUP(uspex_gui.mol_model,0,uspex_mol_model_selected); init_uspex_gdis_mol(); GUI_COMBOBOX_SETUP(uspex_gui.mol_gdis,0,uspex_gdis_mol_selected); - GUI_COMBOBOX_SETUP(uspex_gui.substrate_model,0,uspex_substrate_model_selected); + init_substrate_models(); /* --- Outside of notebook */ GUI_FRAME_WINDOW(uspex_gui.window,frame); GUI_VBOX_FRAME(frame,vbox); diff --git a/src/gui_uspex.h b/src/gui_uspex.h index f0a59bc..ef29c99 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -155,10 +155,10 @@ struct uspex_calc_gui{ GUI_OBJ *KresolStart; GUI_OBJ *vacuumSize; gboolean auto_step; - gchar *_tmp_ai_input; + gchar **_tmp_ai_input; GUI_OBJ *ai_input; GUI_OBJ *ai_input_button; - gchar *_tmp_ai_opt; + gchar **_tmp_ai_opt; GUI_OBJ *ai_opt; GUI_OBJ *ai_opt_button; GUI_OBJ *ai_generate; @@ -170,7 +170,7 @@ struct uspex_calc_gui{ GUI_OBJ *ai_pot_button; GUI_OBJ *numProcessors; GUI_OBJ *numParallelCalcs; - gchar *_tmp_commandExecutable; + gchar **_tmp_commandExecutable; GUI_OBJ *commandExecutable; GUI_OBJ *whichCluster; GUI_OBJ *remoteFolder; @@ -226,6 +226,7 @@ struct uspex_calc_gui{ GUI_OBJ *TE_goal; gchar *_tmp_cmd_BoltzTraP;/*optional, and unused (for now)*/ GUI_OBJ *cmd_BoltzTraP;/*optional, and unused (for now)*/ + GUI_OBJ *cmd_BoltzTraP_button; /*5.3 Surfaces*/ GUI_OBJ *thicknessS; GUI_OBJ *thicknessB; From 81c1af5616aff81c8ad7d85ad852c839f1e11317 Mon Sep 17 00:00:00 2001 From: ovhpa Date: Thu, 22 Nov 2018 21:46:24 +0900 Subject: [PATCH 56/56] gui_uspex: task integration. --- src/gui_uspex.c | 126 +++++++++++++++++++++++++++--------------------- src/gui_uspex.h | 2 + 2 files changed, 73 insertions(+), 55 deletions(-) diff --git a/src/gui_uspex.c b/src/gui_uspex.c index 0318557..034b696 100644 --- a/src/gui_uspex.c +++ b/src/gui_uspex.c @@ -287,6 +287,10 @@ void gui_uspex_init(struct model_pak *model){ if(uspex_gui._potentials!=NULL) g_free(uspex_gui._potentials);/*<- needed?*/ uspex_gui._potentials=g_malloc(uspex_gui.calc._num_opt_steps*sizeof(gchar *)); for(idx=0;idxuspex_gui.calc._num_opt_steps){ /*increase*/ for(idx=0;idx uspex.log",(*uspex_exec).job_uspex_exe); +if(uspex_gui.have_v1010){ + if(uspex_gui.have_octave) cmd = g_strdup_printf("%s > uspex.log",(*uspex_exec).job_uspex_exe); + else cmd = g_strdup_printf("%s -m > uspex.log",(*uspex_exec).job_uspex_exe); +}else{ + if(uspex_gui.have_octave) cmd = g_strdup_printf("%s -9 > uspex.log",(*uspex_exec).job_uspex_exe); + else cmd = g_strdup_printf("%s -m9 > uspex.log",(*uspex_exec).job_uspex_exe); +} #endif cwd=sysenv.cwd;/*push*/ sysenv.cwd=g_strdup_printf("%s",(*uspex_exec).job_path); @@ -3714,40 +3755,10 @@ void run_uspex_exec(uspex_exec_struct *uspex_exec){ /* cleanup task: load result */ /*****************************/ void cleanup_uspex_exec(uspex_exec_struct *uspex_exec){ - /*USPEX process has exit, try to load the result*/ - struct model_pak *result_model; - gchar *filename; - int index; - FILE *vf; + /*USPEX process has exit, DO NOT try to load the result -- yet*/ /*sync_ wait for result?*/ while(!(*uspex_exec).have_result) usleep(500*1000);/*sleep 500ms until job is done*/ - /*init a model*/ - result_model=model_new(); - model_init(result_model); - /*put result into it*/ - /*1- find the last result folder*/ - index=1; - filename=g_strdup_printf("%s/results1/OUTPUT.txt",(*uspex_exec).job_path); - vf=fopen(filename,"r"); - while(vf!=NULL){ - g_free(filename); - fclose(vf); - index++; - filename=g_strdup_printf("%s/results%i/OUTPUT.txt",(*uspex_exec).job_path,index); - vf=fopen(filename,"r"); - } - index--; - g_free(filename); - /*this is the last openable folder/OUTPUT.txt*/ - filename=g_strdup_printf("%s/results%i/OUTPUT.txt",(*uspex_exec).job_path,index); - (*uspex_exec).index=index; - /*TODO: detect if a calculation have failed*/ - file_load(filename,result_model);/*TODO: load result without annoying tree_select_active*/ - model_prep(result_model); - tree_model_add(result_model); - tree_model_refresh(result_model); - canvas_shuffle(); - redraw_canvas(ALL);/*ALL: necessary?*/ + /*TODO: connect an empty model that will be updated with uspex results AS THEY ARRIVE TODO*/ /*just wipe the structure*/ sysenv.uspex_calc_list=g_slist_remove(sysenv.uspex_calc_list,uspex_exec);/*does not free, does it?*/ g_free(uspex_exec); @@ -3793,10 +3804,8 @@ void gui_uspex_dialog(void){ gpointer dialog; GUI_OBJ *frame, *vbox, *hbox, *table; GUI_OBJ *notebook, *page, *button, *label; -// GUI_OBJ *separator; /* special */ struct model_pak *data; -// struct core_pak *core; gint idx; gchar *tmp; /* checks */ @@ -4250,36 +4259,43 @@ GUI_TOOLTIP(uspex_gui.ai_pot,"Per-species (pseudo-)potential files.\nFor pair- a /* --- USPEX launch */ GUI_LABEL_TABLE(table,"USPEX launch",0,4,6,7); /* line 7 */ - /*col 1: empty*/ - GUI_ENTRY_TABLE(table,uspex_gui.numProcessors,uspex_gui.calc.numProcessors,"%i","CPU:",0,1,7,8); -GUI_TOOLTIP(uspex_gui.numProcessors,"numProcessors: Ch. ? DEFAULT: 1\nNumber of processors used in a step (undocumented)."); - GUI_ENTRY_TABLE(table,uspex_gui.numParallelCalcs,uspex_gui.calc.numParallelCalcs,"%i","PAR:",1,2,7,8); -GUI_TOOLTIP(uspex_gui.numParallelCalcs,"numParallelCalcs: Ch. 4.8 DEFAULT: 1\nNumber of structure relaxations in parallel."); + GUI_TEXT_TABLE(table,uspex_gui.job_uspex_exe,uspex_gui.calc.job_uspex_exe,"USPEX:",0,1,7,8); +GUI_TOOLTIP(uspex_gui.job_uspex_exe,"The USPEX script executable."); + GUI_OPEN_BUTTON_TABLE(table,button,load_uspex_exe,1,2,7,8); GUI_ENTRY_TABLE(table,uspex_gui.whichCluster,uspex_gui.calc.whichCluster,"%i","Cluster:",2,3,7,8); GUI_TOOLTIP(uspex_gui.whichCluster,"whichCluster: Ch. 4.8 DEFAULT: 0\nType of job submission, including:\n0 - no job-script;\n1 - local submission;\n2 - remote submission.\n>2 - specific supercomputer."); GUI_CHECK_TABLE(table,button,uspex_gui.calc.PhaseDiagram,NULL,"PhaseDiag",3,4,7,8);/*not calling anything*/ GUI_TOOLTIP(button,"PhaseDiagram: Ch. 4.8 DEFAULT: FALSE\nSet calculation of an estimated phase diagram\nfor calculationMethod 30X (300, 301, s300, and s301)."); /* line 8 */ - GUI_TEXT_TABLE(table,uspex_gui.job_path,uspex_gui.calc.job_path,"Folder:",0,1,8,9); + GUI_CHECK_TABLE(table,button,uspex_gui.have_v1010,NULL,"Ver 10.1",0,1,8,9);/*not calling anything*/ +GUI_TOOLTIP(button,"Use USPEX v. 10.1 instead of 9.4.4."); + GUI_ENTRY_TABLE(table,uspex_gui.numProcessors,uspex_gui.calc.numProcessors,"%i","CPU:",1,2,8,9); +GUI_TOOLTIP(uspex_gui.numProcessors,"numProcessors: Ch. ? DEFAULT: 1\nNumber of processors used in a step (undocumented)."); + GUI_ENTRY_TABLE(table,uspex_gui.numParallelCalcs,uspex_gui.calc.numParallelCalcs,"%i","PAR:",2,3,8,9); +GUI_TOOLTIP(uspex_gui.numParallelCalcs,"numParallelCalcs: Ch. 4.8 DEFAULT: 1\nNumber of structure relaxations in parallel."); + GUI_CHECK_TABLE(table,button,uspex_gui.have_octave,NULL,"OCTAVE",3,4,8,9);/*not calling anything*/ +GUI_TOOLTIP(button,"Use octave instead of matlab."); +/* line 9 */ + GUI_TEXT_TABLE(table,uspex_gui.job_path,uspex_gui.calc.job_path,"Folder:",0,1,9,10); GUI_TOOLTIP(uspex_gui.job_path,"Select USPEX calculation folder.\nThis folder is where run_uspex will be launched\nand result will be read by GDIS."); - GUI_OPEN_BUTTON_TABLE(table,button,uspex_path_dialog,1,2,8,9); - GUI_TEXT_TABLE(table,uspex_gui.remoteFolder,uspex_gui.calc.remoteFolder,"Remote:",2,3,8,9); + GUI_OPEN_BUTTON_TABLE(table,button,uspex_path_dialog,1,2,9,10); + GUI_TEXT_TABLE(table,uspex_gui.remoteFolder,uspex_gui.calc.remoteFolder,"Remote:",2,3,9,10); GUI_TOOLTIP(uspex_gui.remoteFolder,"remoteFolder: Ch. 4.8 DEFAULT: none\nWhen using remote submission, this hold the\nexecution folder on the distant computer."); - GUI_OPEN_BUTTON_TABLE(table,button,load_remote_folder,3,4,8,9); + GUI_OPEN_BUTTON_TABLE(table,button,load_remote_folder,3,4,9,10); /*TODO: disable remote when whichCluster<2*/ /* --- Restart */ - GUI_LABEL_TABLE(table,"Restart",0,4,9,10); -/* line 10 */ - GUI_CHECK_TABLE(table,uspex_gui.pickUpYN,uspex_gui.calc.pickUpYN,NULL,"RESTART",0,1,10,11);/*not calling anything*/ + GUI_LABEL_TABLE(table,"Restart",0,4,10,11); +/* line 11 */ + GUI_CHECK_TABLE(table,uspex_gui.pickUpYN,uspex_gui.calc.pickUpYN,NULL,"RESTART",0,1,11,12);/*not calling anything*/ GUI_TOOLTIP(uspex_gui.pickUpYN,"pickUpYN: deprecated DEFAULT: 0\nSet to restart a calculation, deprecated on version <= 10."); - GUI_ENTRY_TABLE(table,uspex_gui.pickUpGen,uspex_gui.calc.pickUpGen,"%i","GEN:",1,2,10,11); + GUI_ENTRY_TABLE(table,uspex_gui.pickUpGen,uspex_gui.calc.pickUpGen,"%i","GEN:",1,2,11,12); GUI_TOOLTIP(uspex_gui.pickUpGen,"pickUpGen: Ch. 4.7 DEFAULT: 0\nSelect the generation at which USPEX should restart.\nA new calculation is started for 0 (default)."); - GUI_ENTRY_TABLE(table,uspex_gui.pickUpFolder,uspex_gui.calc.pickUpFolder,"%i","Folder:",2,3,10,11); + GUI_ENTRY_TABLE(table,uspex_gui.pickUpFolder,uspex_gui.calc.pickUpFolder,"%i","Folder:",2,3,11,12); GUI_TOOLTIP(uspex_gui.pickUpFolder,"pickUpFolder: Ch. 4.7 DEFAULT: 0\nSelect the folder number from which to restart from.\nSetting N means restarting from a folder named \"resultN\"."); - GUI_CHECK_TABLE(table,button,uspex_gui.restart_cleanup,NULL,"CLEANUP",3,4,10,11);/*not calling anything*/ + GUI_CHECK_TABLE(table,button,uspex_gui.restart_cleanup,NULL,"CLEANUP",3,4,11,12);/*not calling anything*/ GUI_TOOLTIP(button,"Cleanup the calculation directory before restart,\nie. remove still_running, NOT_YET, 0PhaseDiagram: Ch. 4.8 DEFAULT: FALSE\nSet calculation of an estimated phase diagram\nfor calculationMethod 30X (300, 301, s300, and s301)."); /* reserved for future use */ - for(idx=11;idx<18;idx++) GUI_LABEL_TABLE(table," ",0,4,idx,idx+1); + for(idx=12;idx<18;idx++) GUI_LABEL_TABLE(table," ",0,4,idx,idx+1); /* --- end page */ /*--------------------*/ diff --git a/src/gui_uspex.h b/src/gui_uspex.h index ef29c99..1537e46 100644 --- a/src/gui_uspex.h +++ b/src/gui_uspex.h @@ -306,6 +306,8 @@ struct uspex_calc_gui{ GUI_OBJ *job_uspex_exe; GUI_OBJ *job_path; gboolean have_result; + gboolean have_v1010; + gboolean have_octave; gint index; /*buttons*/ GUI_OBJ *button_save;