1 /* MopacRem.c */
2 /**********************************************************************************************************
3 Copyright (c) 2002-2013 Abdul-Rahman Allouche. All rights reserved
4
5 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6 documentation files (the Gabedit), to deal in the Software without restriction, including without limitation
7 the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
8 and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
10 The above copyright notice and this permission notice shall be included in all copies or substantial portions
11 of the Software.
12
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
14 TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
16 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17 DEALINGS IN THE SOFTWARE.
18 ************************************************************************************************************/
19
20 #include <stdlib.h>
21 #include <ctype.h>
22 #include <math.h>
23 #include <string.h>
24
25 #include "../../Config.h"
26 #include "../Common/Global.h"
27 #include "../Mopac/MopacTypes.h"
28 #include "../Mopac/MopacGlobal.h"
29 #include "../Mopac/MopacMolecule.h"
30 #include "../Utils/Utils.h"
31 #include "../Utils/UtilsInterface.h"
32 #include "../Utils/GabeditTextEdit.h"
33 #include "../Common/Windows.h"
34 #include "../Utils/Constants.h"
35
36 static GtkWidget* comboethod = NULL;
37 /*************************************************************************************************************/
38 static gchar* listJobView[] = {
39 "Single Point Energy",
40 "Equilibrium structure search",
41 "Frequencies",
42 "Transition structure search",
43 "Theromochemical Calculations",
44 "Molecular Orbitals",
45 "Atomic charges from ElectroStatic Potential",
46 "Reaction path",
47 };
48 static gchar* listJobReal[] = {
49 "1SCF ",
50 "XYZ ",
51 "FORCE ",
52 "TS ",
53 "THERMO ROT=1 ",
54 "GRAPH VECTORS ",
55 "1SCF ESP ",
56 "RP",
57 };
58 static guint numberOfJobs = G_N_ELEMENTS (listJobView);
59 static gchar selectedJob[BSIZE]="1SCF";
60 /*************************************************************************************************************/
61 static gchar* listHamiltonianMethodsView[] =
62 {
63 "PM7",
64 "PM6",
65 "PM6-DH+",
66 "PM6-DH2",
67 "RM1",
68 "PM3",
69 "AM1",
70 "MNDO",
71 };
72 static gchar* listHamiltonianMethodsReal[] =
73 {
74 "PM7",
75 "PM6",
76 "PM6-DH+",
77 "PM6-DH2",
78 "RM1",
79 "PM3",
80 "AM1",
81 "MNDO",
82 };
83 static guint numberOfHamiltonianMethods = G_N_ELEMENTS (listHamiltonianMethodsView);
84 static gchar selectedHamiltonian[BSIZE]="PM7";
85 /*************************************************************************************************************/
86 static gchar* listSolventsView[] =
87 {
88 "Nothing",
89 "Water [H2O]",
90 "AceticAcid [CH3COOH]",
91 "Acetone [CH3COCH3]",
92 "Acetonitrile [CH3CN]",
93 "Ammonia [NH3]",
94 "Aniline [C6H5NH2]",
95 "Benzene [C6H6]",
96 "BenzylAlcohol [C6H5CH2OH]",
97 "Bromoform [CHBr3]",
98 "Butanol [C4H9OH]",
99 "isoButanol [(CH3)2CHCH2OH]",
100 "tertButanol [(CH3)3COH]",
101 "CarbonDisulfide [CS2]",
102 "CarbonTetrachloride [CCl4]",
103 "Chloroform [CHCl3]",
104 "Cyclohexane [C6H12]",
105 "Cyclohexanone [C6H10O]",
106 "Dichlorobenzene [C6H4Cl2]",
107 "DiethylEther [(CH3CH2)2O]",
108 "Dioxane [C4H8O2]",
109 "DMFA [(CH3)2NCHO]",
110 "DMSO [(CH3)2SO]",
111 "Ethanol [CH3CH2OH]",
112 "EthylAcetate [CH3COOCH2CH3]",
113 "Dichloroethane [ClCH2CH2Cl]",
114 "EthyleneGlycol [HOCH2CH2OH]",
115 "Formamide [HCONH2]",
116 "FormicAcid [HCOOH]",
117 "Glycerol [C3H8O3]",
118 "HexamethylPhosphoramide [C6H18N3OP]",
119 "Hexane [C6H14]",
120 "Hydrazine [N2H4]",
121 "Methanol [CH3OH]",
122 "MethylEthylKetone [CH3CH2COCH3]",
123 "Dichloromethane [CH2Cl2]",
124 "Methylformamide [HCONHCH3]",
125 "Methypyrrolidinone [C5H9NO]",
126 "Nitrobenzene [C6H5NO2]",
127 "Nitrogen [N2]",
128 "Nitromethane [CH3NO2]",
129 "PhosphorylChloride [POCl3]",
130 "IsoPropanol [(CH3)2CHOH]",
131 "Pyridine [C5H5N]",
132 "Sulfolane [C4H8SO2]",
133 "Tetrahydrofuran [C4H8O]",
134 "Toluene [C6H5CH3]",
135 "Triethylamine [(CH3CH2)3N]",
136 "TrifluoroaceticAcid [CF3COOH]",
137 };
138
139 static gchar* listSolventsReal[] =
140 {
141 " ",
142 "EPS=78.39 RSOLV=1.3",
143 "EPS=6.19 RSOLV=2.83",
144 "EPS=20.7 RSOLV=3.08",
145 "EPS=37.5 RSOLV=2.76",
146 "EPS=16.9 RSOLV=2.24",
147 "EPS=6.8 RSOLV=3.31",
148 "EPS=2.3 RSOLV=3.28",
149 "EPS=13.1 RSOLV=3.45",
150 "EPS=4.3 RSOLV=3.26",
151 "EPS=17.5 RSOLV=3.31",
152 "EPS=17.9 RSOLV=3.33",
153 "EPS=12.4 RSOLV=3.35",
154 "EPS=2.6 RSOLV=2.88",
155 "EPS=2.2 RSOLV=3.37",
156 "EPS=4.8 RSOLV=3.17",
157 "EPS=2.0 RSOLV=3.5",
158 "EPS=15.0 RSOLV=3.46",
159 "EPS=9.8 RSOLV=3.54",
160 "EPS=4.34 RSOLV=3.46",
161 "EPS=2.2 RSOLV=3.24",
162 "EPS=37.0 RSOLV=3.13",
163 "EPS=46.7 RSOLV=3.04",
164 "EPS=24.55 RSOLV=2.85",
165 "EPS=6.02 RSOLV=3.39",
166 "EPS=10.66 RSOLV=3.15",
167 "EPS=37.7 RSOLV=2.81",
168 "EPS=109.5 RSOLV=2.51",
169 "EPS=58.5 RSOLV=2.47",
170 "EPS=42.5 RSOLV=3.07",
171 "EPS=43.3 RSOLV=4.1",
172 "EPS=1.88 RSOLV=3.74",
173 "EPS=51.7 RSOLV=2.33",
174 "EPS=32.6 RSOLV=2.53",
175 "EPS=18.5 RSOLV=3.3",
176 "EPS=8.9 RSOLV=2.94",
177 "EPS=182.4 RSOLV=2.86",
178 "EPS=33.0 RSOLV=3.36",
179 "EPS=34.8 RSOLV=3.44",
180 "EPS=1.45 RSOLV=2.36",
181 "EPS=35.87 RSOLV=2.77",
182 "EPS=13.9 RSOLV=3.33",
183 "EPS=19.9 RSOLV=3.12",
184 "EPS=12.4 RSOLV=3.18",
185 "EPS=43.3 RSOLV=3.35",
186 "EPS=7.58 RSOLV=3.18",
187 "EPS=2.38 RSOLV=3.48",
188 "EPS=2.44 RSOLV=3.81",
189 "EPS=42.1 RSOLV=3.12",
190 };
191 static guint numberOfSolvents = G_N_ELEMENTS (listSolventsView);
192 static gchar selectedSolvent[BSIZE]="Nothing";
193 /*************************************************************************************************************/
getSeletedJobType()194 gchar* getSeletedJobType()
195 {
196 return selectedJob;
197 }
198 /*************************************************************************************************************/
calculWord(gchar * view)199 static gchar* calculWord(gchar* view)
200 {
201 gint i;
202 for(i=0;i<numberOfJobs;i++)
203 {
204 if(strcmp(view,listJobView[i])==0)return listJobReal[i];
205 }
206 return NULL;
207 }
208 /*************************************************************************************************************/
putMopacJobTypeInfoInTextEditor()209 static void putMopacJobTypeInfoInTextEditor()
210 {
211 if(!strcmp(selectedJob,"RP")) putMopacReactionPathInTextEditor();
212 else gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedJob,-1);
213 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
214 }
215 /*************************************************************************************************************/
putMopacHamiltonianInfoInTextEditor()216 static void putMopacHamiltonianInfoInTextEditor()
217 {
218 if(strcmp(selectedHamiltonian,"NONE")==0)return;
219
220 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedHamiltonian,-1);
221 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
222 }
223 /*************************************************************************************************************/
putMopacSolventInfoInTextEditor()224 static void putMopacSolventInfoInTextEditor()
225 {
226 if(strcmp(selectedSolvent,"Nothing")==0)return;
227
228 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, selectedSolvent,-1);
229 gabedit_text_insert (GABEDIT_TEXT(text), NULL, NULL, NULL, " ",-1);
230 }
231 /*************************************************************************************************************/
putMopacRemInfoInTextEditor()232 void putMopacRemInfoInTextEditor()
233 {
234 putMopacHamiltonianInfoInTextEditor();
235 putMopacJobTypeInfoInTextEditor();
236 putMopacSolventInfoInTextEditor();
237 }
238 /************************************************************************************************************/
traitementJobType(GtkComboBox * combobox,gpointer d)239 static void traitementJobType (GtkComboBox *combobox, gpointer d)
240 {
241 GtkTreeIter iter;
242 gchar* data = NULL;
243 gchar* res = NULL;
244 GtkWidget* hboxRP = NULL;
245
246 if (gtk_combo_box_get_active_iter (combobox, &iter))
247 {
248 GtkTreeModel* model = gtk_combo_box_get_model(combobox);
249 gtk_tree_model_get (model, &iter, 0, &data, -1);
250 }
251 else return;
252 res = calculWord(data);
253 if(res) sprintf(selectedJob,"%s",res);
254 else sprintf(selectedJob,"SP");
255 hboxRP = g_object_get_data(G_OBJECT (combobox), "HboxReactionPath");
256 if(hboxRP && GTK_IS_WIDGET(hboxRP)) gtk_widget_set_sensitive(hboxRP, strstr(data,"Reaction path")!=NULL);
257
258 }
259 /********************************************************************************************************/
create_list_jobtype()260 static GtkWidget *create_list_jobtype()
261 {
262 GtkTreeIter iter;
263 GtkTreeStore *store;
264 GtkTreeModel *model;
265 GtkWidget *combobox;
266 GtkCellRenderer *renderer;
267 gint i;
268 GtkTreeIter iter0;
269
270 store = gtk_tree_store_new (1,G_TYPE_STRING);
271
272 for(i=0;i<numberOfJobs;i++)
273 {
274 gtk_tree_store_append (store, &iter, NULL);
275 if(i==0) iter0 = iter;
276 gtk_tree_store_set (store, &iter, 0, listJobView[i], -1);
277 }
278
279 model = GTK_TREE_MODEL (store);
280 combobox = gtk_combo_box_new_with_model (model);
281 /*
282 gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
283 */
284 g_object_unref (model);
285 g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementJobType), NULL);
286 renderer = gtk_cell_renderer_text_new ();
287 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
288 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
289
290 gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
291
292 return combobox;
293 }
294 /************************************************************************************************************/
traitementHamiltonian(GtkComboBox * combobox,gpointer d)295 static void traitementHamiltonian (GtkComboBox *combobox, gpointer d)
296 {
297 GtkTreeIter iter;
298 gchar* data = NULL;
299 gchar* res = NULL;
300 gint i;
301 /* gchar* s;*/
302 if (gtk_combo_box_get_active_iter (combobox, &iter))
303 {
304 GtkTreeModel* model = gtk_combo_box_get_model(combobox);
305 gtk_tree_model_get (model, &iter, 0, &data, -1);
306 }
307 else return;
308 for(i=0;i<numberOfHamiltonianMethods;i++)
309 {
310 if(strcmp((gchar*)data,listHamiltonianMethodsView[i])==0) res = listHamiltonianMethodsReal[i];
311 }
312 if(res) sprintf(selectedHamiltonian,"%s",res);
313
314 }
315 /********************************************************************************************************/
create_list_hamiltonian_methods()316 static GtkWidget *create_list_hamiltonian_methods()
317 {
318 GtkTreeIter iter;
319 GtkTreeStore *store;
320 GtkTreeModel *model;
321 GtkWidget *combobox;
322 GtkCellRenderer *renderer;
323 gint i;
324 GtkTreeIter iter0;
325
326 store = gtk_tree_store_new (1,G_TYPE_STRING);
327
328 for(i=0;i<numberOfHamiltonianMethods;i++)
329 {
330 gtk_tree_store_append (store, &iter, NULL);
331 if(i==0) iter0 = iter;
332 gtk_tree_store_set (store, &iter, 0, listHamiltonianMethodsView[i], -1);
333 }
334
335 model = GTK_TREE_MODEL (store);
336 combobox = gtk_combo_box_new_with_model (model);
337 /*
338 gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
339 */
340 g_object_unref (model);
341 g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementHamiltonian), NULL);
342 renderer = gtk_cell_renderer_text_new ();
343 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
344 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
345
346 gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
347
348 return combobox;
349 }
350 /************************************************************************************************************/
traitementSolventType(GtkComboBox * combobox,gpointer d)351 static void traitementSolventType (GtkComboBox *combobox, gpointer d)
352 {
353 GtkTreeIter iter;
354 gchar* data = NULL;
355 gchar* res = NULL;
356 gint i;
357
358 if (gtk_combo_box_get_active_iter (combobox, &iter))
359 {
360 GtkTreeModel* model = gtk_combo_box_get_model(combobox);
361 gtk_tree_model_get (model, &iter, 0, &data, -1);
362 }
363 else return;
364 for(i=0;i<numberOfSolvents;i++)
365 {
366 if(strcmp((gchar*)data,listSolventsView[i])==0) res = listSolventsReal[i];
367 }
368 if(res) sprintf(selectedSolvent,"%s",res);
369 else sprintf(selectedSolvent,"Nothing");
370
371 }
372 /********************************************************************************************************/
create_list_solventtype()373 static GtkWidget *create_list_solventtype()
374 {
375 GtkTreeIter iter;
376 GtkTreeStore *store;
377 GtkTreeModel *model;
378 GtkWidget *combobox;
379 GtkCellRenderer *renderer;
380 gint i;
381 GtkTreeIter iter0;
382
383 store = gtk_tree_store_new (1,G_TYPE_STRING);
384
385 for(i=0;i<numberOfSolvents;i++)
386 {
387 gtk_tree_store_append (store, &iter, NULL);
388 if(i==0) iter0 = iter;
389 gtk_tree_store_set (store, &iter, 0, listSolventsView[i], -1);
390 }
391
392 model = GTK_TREE_MODEL (store);
393 combobox = gtk_combo_box_new_with_model (model);
394 /*
395 gtk_combo_box_set_add_tearoffs (GTK_COMBO_BOX (combobox), TRUE);
396 */
397 g_object_unref (model);
398 g_signal_connect (G_OBJECT(combobox), "changed", G_CALLBACK(traitementSolventType), NULL);
399 renderer = gtk_cell_renderer_text_new ();
400 gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combobox), renderer, TRUE);
401 gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combobox), renderer, "text", 0, NULL);
402
403 gtk_combo_box_set_active_iter(GTK_COMBO_BOX (combobox), &iter0);
404
405 return combobox;
406 }
407 /*************************************************************************************************************/
createMopacRemFrame(GtkWidget * win,GtkWidget * box)408 void createMopacRemFrame(GtkWidget *win, GtkWidget *box)
409 {
410 GtkWidget* frame;
411 GtkWidget* vboxFrame;
412 GtkWidget* combo = NULL;
413 gint l=0;
414 gint c=0;
415 gint ncases=1;
416 GtkWidget *table = gtk_table_new(8,3,FALSE);
417
418 comboethod = NULL;
419
420 frame = gtk_frame_new (_("Job Specification:"));
421 gtk_widget_show (frame);
422 gtk_box_pack_start (GTK_BOX (box), frame, TRUE, TRUE, 3);
423 gtk_frame_set_label_align (GTK_FRAME (frame), 0.5, 0.5);
424
425 vboxFrame = gtk_vbox_new (FALSE, 3);
426 gtk_widget_show (vboxFrame);
427 gtk_container_add (GTK_CONTAINER (frame), vboxFrame);
428 gtk_box_pack_start (GTK_BOX (vboxFrame), table, TRUE, TRUE, 0);
429
430 /*------------------ Job Type -----------------------------------------*/
431 l=0;
432 c = 0; ncases=1;
433 add_label_table(table,_("Job Type"),l,c);
434 c = 1; ncases=1;
435 add_label_table(table,":",l,c);
436 combo = create_list_jobtype();
437 c = 2; ncases=1;
438 gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
439 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
440 (GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
441 2,2);
442 g_object_set_data(G_OBJECT (win), "ComboJobType", combo);
443 /*------------------ Hamiltonian Type -----------------------------------------*/
444 l++;
445 c = 0; ncases=1;
446 add_label_table(table,_("Hamiltonian"),l,c);
447 c = 1; ncases=1;
448 add_label_table(table,":",l,c);
449 combo = create_list_hamiltonian_methods();
450 comboethod = combo;
451 c = 2; ncases=1;
452 gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
453 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
454 (GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
455 2,2);
456 l++;
457 c = 0; ncases=1;
458 add_label_table(table,_("Solvent"),l,c);
459 c = 1; ncases=1;
460 add_label_table(table,":",l,c);
461 combo = create_list_solventtype();
462 c = 2; ncases=1;
463 gtk_table_attach(GTK_TABLE(table),combo,c,c+ncases,l,l+1,
464 (GtkAttachOptions) (GTK_FILL | GTK_EXPAND),
465 (GtkAttachOptions) (GTK_FILL | GTK_SHRINK),
466 2,2);
467 }
468