atomes 1.2.1
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
dlp_edit.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2025 by CNRS and University of Strasbourg */
15
22/*
23* This file: 'dlp_edit.c'
24*
25* Contains:
26*
27
28 - The functions to edit DL-POLY force field parameters
29
30*
31* List of functions:
32
33 int get_num_vdw_max ();
34
35 gboolean are_identical_prop (int ti, int ai, field_prop * pro_a, field_prop * pro_b);
36 gboolean tersoff_question ();
37 gboolean body_identicals (field_nth_body * body, int nbd, int * na, int ** ma, int ** ba);
38
39 gchar * get_this_vdw_string ();
40 gchar * field_str (int a);
41 gchar * body_str (int a);
42 gchar * get_body_element_name (field_nth_body * body, int aid, int nbd);
43
44 void adjust_field_prop (int fil, int sti, field_prop * tmp, int * ids, int key);
45 void select_atom_set_color (GtkCellRenderer * renderer, int i);
46 void select_atom_set_cmv (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data);
47 void update_field_dist (float v);
48 void adjust_vdw_interactions (gboolean add_shell);
49 void edit_parameters (int f, int id);
50 void update_tersoffs (int id, int key);
51 void check_tersoffs (int id, int key);
52
53 G_MODULE_EXPORT void update_atom_parameter (GtkEntry * res, gpointer data);
54 G_MODULE_EXPORT void update_field_parameter (GtkEntry * res, gpointer data);
55 G_MODULE_EXPORT void update_cross_parameter (GtkEntry * res, gpointer data);
56 G_MODULE_EXPORT void changed_cross_combo (GtkComboBox * box, gpointer data);
57 G_MODULE_EXPORT void changed_field_key_combo (GtkComboBox * box, gpointer data);
58 G_MODULE_EXPORT void visualize_it (GtkCheckButton * but, gpointer data);
59 G_MODULE_EXPORT void visualize_it (GtkToggleButton * but, gpointer data);
60 G_MODULE_EXPORT void select_it (GtkCheckButton * but, gpointer data);
61 G_MODULE_EXPORT void select_it (GtkToggleButton * but, gpointer data);
62 G_MODULE_EXPORT void field_molecule_select_atom_id (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data);
63 G_MODULE_EXPORT void edit_unit_weight (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data);
64 G_MODULE_EXPORT void select_atom_id_from_fied_molecule (GtkButton * but, gpointer data);
65 G_MODULE_EXPORT void selection_button (GtkButton * but, gpointer data);
66 G_MODULE_EXPORT void changed_atom_combo (GtkComboBox * box, gpointer data);
67 G_MODULE_EXPORT void shell_in_vdw (GtkCheckButton * but, gpointer data);
68 G_MODULE_EXPORT void shell_in_vdw (GtkToggleButton * but, gpointer data);
69 G_MODULE_EXPORT void run_edit_parameters (GtkDialog * dialog, gint response_id, gpointer data);
70 G_MODULE_EXPORT void edit_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data);
71 G_MODULE_EXPORT void add_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data);
72 G_MODULE_EXPORT void remove_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data);
73
74 GtkWidget * combo_cross (field_nth_body * body);
75 GtkWidget * parameters_box (int obj, int key, gchar ** words, float * data);
76 GtkWidget * param_prop_param_box (int pid);
77
78*/
79
80#include "global.h"
81#include "interface.h"
82#include "glwindow.h"
83#include "glview.h"
84#include "dlp_field.h"
85#include "calc.h"
86
87extern int * atoms_id;
88extern int ** atoms_id_list;
89extern char *** ff_atoms;
90
91extern gchar * felemts[MAXDATA+1];
92extern gchar * elemts[MAXDATA];
93extern gchar * mo_title[8];
94
95extern int fetypes[2][16];
96
97extern void clean_up_molecules_info (gboolean usel);
98extern void select_object (int id, int jd, int kd);
99extern G_MODULE_EXPORT void run_add_atom_dialog (GtkDialog * add_dialog, gint response_id, gpointer data);
100extern void field_selection (int i, int viz, int lab, int aid);
101extern void field_unselect_all ();
102extern void compare_non_bonded (gchar * fatom);
103extern void visualize_single_struct (int id, int jd, int kd, int * ids);
104extern void visualize_body (int viz, int bd, field_nth_body * body);
105extern void init_default_shaders (glwin * view);
106extern GtkWidget * create_field_prop_combo (int f, int is_moy);
107extern void check_atom_for_updates ();
109extern GtkWidget * ff_p_combo[2];
110
111GtkWidget * field_key_combo;
112GtkWidget * p_box;
113GtkWidget * cross_vbox, * cross_hbox;
114GtkWidget * param_box;
115GtkWidget * img_but[4];
116GtkWidget * shell_but;
117
118GtkWidget * shell_hbox[3];
119GtkWidget * shell_cbox[2];
120GtkWidget * body_lab;
121GtkWidget * afftype;
124
135gboolean are_identical_prop (int ti, int ai, field_prop * pro_a, field_prop * pro_b)
136{
137 if (pro_a -> key != pro_b -> key) return FALSE;
138 if (pro_a -> use != pro_b -> use) return FALSE;
139 if (pro_a -> show != pro_b -> show) return FALSE;
140 int i;
141 /*for (i=0; i<ai; i++)
142 {
143 if (pro_a -> aid[i] != pro_b -> aid[i]) return FALSE;
144 }*/
145 for (i=0; i<fvalues[activef][ti][pro_a -> key]; i++)
146 {
147 if (pro_a -> val[i] != pro_b -> val[i]) return FALSE;
148 }
149 return TRUE;
150}
151
163void adjust_field_prop (int fil, int sti, field_prop * tmp, int * ids, int key)
164{
165 int i, j, k, l;
166 gboolean add;
167 add = FALSE;
168 field_prop * pro, * ptmp;
169 if (ids[0] < 0)
170 {
171 // Default prop
172 if (tmp == NULL)
173 {
174 // New val for default field prop
175 tmp_fstr -> def = init_field_prop (fil, key, tmp_fstr -> def -> show, tmp_fstr -> def -> use);
176 }
177 else
178 {
179 tmp_fstr -> def = duplicate_field_prop (tmp, fil);
180 }
181 }
182 else
183 {
184 // Not default, between specified atoms
185 if (tmp != NULL)
186 {
187 pro = get_active_prop_using_atoms (tmp_fstr -> other, sti, ids);
188 if (pro == NULL)
189 {
190 // No 'other' yet, but is it identical to default ?
191 if (! are_identical_prop (fil+1, sti, tmp, tmp_fstr -> def))
192 {
193 add = TRUE;
194 }
195 }
196 else if (! are_identical_prop (fil+1, sti, tmp, pro))
197 {
198 add = TRUE;
199 }
200 }
201 else
202 {
203 if (tmp_fstr -> other == NULL)
204 {
205 add = TRUE;
206 j = key;
207 k = tmp_fstr -> def -> show;
208 l = tmp_fstr -> def -> use;
209 }
210 else
211 {
212 pro = get_active_prop_using_atoms (tmp_fstr -> other, sti, ids);
213 if (pro == NULL)
214 {
215 if (key != tmp_fstr -> def -> key)
216 {
217 add = TRUE;
218 j = key;
219 k = tmp_fstr -> def -> show;
220 l = tmp_fstr -> def -> use;
221 }
222 }
223 else if (key != pro -> key)
224 {
225 add = TRUE;
226 j = key;
227 }
228 }
229 }
230
231 if (add)
232 {
233 if (tmp_fstr -> other == NULL)
234 {
235 if (tmp != NULL)
236 {
237 tmp_fstr -> other = duplicate_field_prop (tmp, fil);
238 }
239 else
240 {
241 tmp_fstr -> other = init_field_prop (fil, j, k, l);
242 for (i=0; i<sti; i++) tmp_fstr -> other -> aid[i] = ids[i];
243 }
244 }
245 else if (pro == NULL)
246 {
247 pro = tmp_fstr -> other;
248 while (pro -> next != NULL) pro = pro -> next;
249 if (tmp != NULL)
250 {
251 pro -> next = duplicate_field_prop (tmp, fil);
252 }
253 else
254 {
255 pro -> next = init_field_prop (fil, j, k, l);
256 pro = pro -> next;
257 for (i=0; i<sti; i++) pro -> aid[i] = ids[i];
258 }
259 }
260 else
261 {
262 if (tmp != NULL)
263 {
264 // Modifying an existing 'other' prop
265 pro -> key = tmp -> key;
266 pro -> val = NULL;
267 if (fvalues[activef][fil+1][tmp -> key] > 0)
268 {
269 pro -> val = duplicate_float (fvalues[activef][fil+1][tmp -> key], tmp -> val);
270 }
271 pro -> show = tmp -> show;
272 pro -> use = tmp -> use;
273 }
274 else
275 {
276 pro -> key = j;
277 pro -> val = NULL;
278 pro -> val = allocfloat (fvalues[activef][fil+1][j]);
279 }
280 }
281 }
282 }
283
284 if (tmp_fstr -> other != NULL)
285 {
286 ptmp = tmp_fstr -> other;
287 while (ptmp)
288 {
289 if (are_identical_prop (fil+1, sti, ptmp, tmp_fstr -> def))
290 {
291 if (ptmp -> next != NULL)
292 {
293 if (ptmp -> prev != NULL)
294 {
295 ptmp -> prev -> next = ptmp -> next;
296 ptmp -> next -> prev = ptmp -> prev;
297 }
298 else
299 {
300 ptmp -> next -> prev = NULL;
301 }
302 }
303 else if (ptmp -> prev != NULL)
304 {
305 ptmp -> prev -> next = NULL;
306 }
307 else
308 {
309 g_free (tmp_fstr -> other);
310 tmp_fstr -> other = NULL;
311 ptmp = NULL;
312 }
313 }
314 if (ptmp) ptmp = ptmp -> next;
315 }
316 }
317 if (tmp_fstr -> other != NULL)
318 {
319 ptmp = tmp_fstr -> other;
320 ptmp -> pid = 0;
321 while (ptmp -> next != NULL)
322 {
323 ptmp -> next -> pid = ptmp -> pid + 1;
324 ptmp = ptmp -> next;
325 }
326 }
327}
328
337G_MODULE_EXPORT void update_atom_parameter (GtkEntry * res, gpointer data)
338{
339 int i = GPOINTER_TO_INT(data);
340 double v;
341 const gchar * m = entry_get_text (res);
342 if (i > -1)
343 {
344 v = string_to_double ((gpointer)m);
346 }
347 switch (i)
348 {
349 case -1:
350 tmp_fat -> name = g_strdup_printf ("%s", m);
351 break;
352 case 0:
353 tmp_fat -> mass = v;
354 break;
355 case 1:
356 tmp_fat -> charge = v;
357 break;
358 case 2:
359 tmp_fshell -> m = v;
360 break;
361 case 3:
362 tmp_fshell -> z = v;
363 break;
364 case 4:
365 tmp_fshell -> k2 = v;
366 break;
367 case 5:
368 tmp_fshell -> k4 = v;
369 break;
370 case 6:
371 tmp_fcons -> length = v;
372 break;
373 case 7:
374 tmp_fpmf -> length = v;
375 break;
376 }
377}
378
380
389G_MODULE_EXPORT void update_field_parameter (GtkEntry * res, gpointer data)
390{
391 int i = GPOINTER_TO_INT(data);
392 const gchar * m = entry_get_text (res);
393 double v = string_to_double ((gpointer)m);
395 if (object_is > 0 && object_is < 9)
396 {
397 tmp_fprop -> val[i] = v;
398 }
399 else
400 {
401 switch (object_is)
402 {
403 case 0:
404 tmp_ftet -> val[i] = v;
405 break;
406 case 14:
407 tmp_fext -> val[i] = v;
408 break;
409 default:
410 tmp_fbody -> val[i] = v;
411 break;
412 }
413 }
414}
415
416GtkWidget * centry[3];
417GtkWidget * cross_box;
418double *** cross = NULL;
421
430G_MODULE_EXPORT void update_cross_parameter (GtkEntry * res, gpointer data)
431{
432 int j, k;
433 k = GPOINTER_TO_INT(data);
434 const gchar * m = entry_get_text (res);
435 double v = string_to_double ((gpointer)m);
438 cross[tmp_fbody -> id][j][k] = cross[j][tmp_fbody -> id][k] = v;
439}
440
449G_MODULE_EXPORT void changed_cross_combo (GtkComboBox * box, gpointer data)
450{
451 int i, j;
452 i = combo_get_active ((GtkWidget *)box);
453 for (j=0; j<3; j++)
454 {
455 // g_debug ("Updating entry:: id= %d, i= %d, j= %d", tmp_fbody -> id, i, j);
456 update_entry_double (GTK_ENTRY(centry[j]), cross[tmp_fbody -> id][i][j]);
457 }
458}
459
467GtkWidget * combo_cross (field_nth_body * body)
468{
469 GtkWidget * combo;
470 combo = create_combo ();
471 g_signal_connect (G_OBJECT(combo), "changed", G_CALLBACK(changed_cross_combo), NULL);
472 if (tmp_field -> first_body[2] && tmp_fbody -> na[0] > -1)
473 {
474 field_nth_body * obody;
475 obody = tmp_field -> first_body[2];
476 while (obody)
477 {
478 combo_text_append (combo, get_active_atom(obody -> ma[0][0], obody -> a[0][0]) -> name);
479 obody = obody -> next;
480 }
481 }
482 return combo;
483}
484
491{
492 gchar * str = NULL;
493 if (tmp_field -> type <= CHARMMSI || tmp_field -> type > COMPASS)
494 {
495 str = g_strdup_printf ("<i>U</i>(r<sub>ij</sub>) = <b>Ɛ<sub>ij</sub></b> x [ (<b>r0<sub>ij</sub></b>/r<sub>ij</sub>)<sup>12</sup> - 2.0 (<b>r0<sub>ij</sub></b>/r<sub>ij</sub>)<sup>6</sup> ]\n"
496 "\t\twith <b>Ɛ<sub>ij</sub></b> = sqrt (Ɛ<sub>i</sub> x Ɛ<sub>j</sub>)\n"
497 "\t\tand <b>r0<sub>ij</sub></b> = r0<sub>i</sub>/2.0 + r0<sub>j</sub>/2.0");
498 }
499 else if (tmp_field -> type == CVFF || tmp_field -> type == CVFF_AUG)
500 {
501 str = g_strdup_printf ("<i>U</i>(r<sub>ij</sub>) = (<b>A<sub>ij</sub></b>/r<sub>ij</sub>)<sup>12</sup> - 2.0 (<b>B<sub>ij</sub></b>/r<sub>ij</sub>)<sup>6</sup>\n"
502 "\t\twith <b>A<sub>ij</sub></b> = sqrt (A<sub>i</sub> x A<sub>j</sub>)\n"
503 "\t\tand <b>B<sub>ij</sub></b> = sqrt (B<sub>i</sub> x B<sub>j</sub>)");
504 }
505 else if (tmp_field -> type >= CFF91 && tmp_field -> type <= COMPASS)
506 {
507 str = g_strdup_printf ("<i>U</i>(r<sub>ij</sub>) = <b>Ɛ<sub>ij</sub></b> x [ 2.0 (<b>r0<sub>ij</sub></b>/r<sub>ij</sub>)<sup>9</sup> - 3.0 (<b>r0<sub>ij</sub></b>/r<sub>ij</sub>)<sup>6</sup> ]\n"
508 "\t\twith <b>Ɛ<sub>ij</sub></b> = 2.0 sqrt (Ɛ<sub>i</sub> x Ɛ<sub>j</sub>) x (r0<sub>i</sub><sup>3</sup> r0<sub>j</sub><sup>3</sup>) / (r0<sub>i</sub><sup>6</sup> + r0<sub>j</sub><sup>6</sup>)\n"
509 "\t\tand <b>r0<sub>ij</sub></b> = [(r0<sub>i</sub><sup>6</sup> + r0<sub>j</sub><sup>6</sup>)/2.0] <sup>1/6</sup>");
510 }
511 return str;
512}
513
524GtkWidget * parameters_box (int obj, int key, gchar ** words, float * data)
525{
526 int i;
527 gchar * str = NULL;
528 GtkWidget * vbox = create_vbox (BSEP);
529 GtkWidget * hbox;
530 GtkWidget * lab;
531 GtkWidget * entry;
532 object_is = obj;
533
534 if (obj > -1 && key > -1)
535 {
536 if (fvalues[activef][obj][key] > 0)
537 {
538 for (i=0; i< fvalues[activef][obj][key]; i++)
539 {
540 if (obj == 11 && key == 0 && i == 0)
541 {
542 hbox = create_hbox (0);
543 lab = markup_label ("<u><i>Single terms:</i></u>", 100, 50, 0.0, 0.5);
544 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
545 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
546 }
547 hbox = create_hbox (0);
548 str = g_strdup_printf (" <b><i>%s</i></b>", words[i]);
549 lab = markup_label (str, 100, -1, 0.0, 0.5);
550 g_free (str);
551 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 50);
552 entry = create_entry (G_CALLBACK(update_field_parameter), 100, 15, FALSE, GINT_TO_POINTER(i));
553 update_entry_double (GTK_ENTRY(entry), data[i]);
554 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
555 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
556 }
557 if (obj == 11 && key == 0)
558 {
560 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, cross_vbox, FALSE, FALSE, 0);
562 lab = markup_label ("<u><i>Cross terms with atom:</i></u>", 160, -1, 0.0, 0.5);
563 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, lab, FALSE, FALSE, 30);
565 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, cross_box, FALSE, FALSE, 0);
566 add_box_child_start (GTK_ORIENTATION_VERTICAL, cross_vbox, cross_hbox, FALSE, FALSE, 10);
567 for (i=11; i< 14; i++)
568 {
569 hbox = create_hbox (0);
570 str = g_strdup_printf (" <b><i>%s</i></b>", words[i]);
571 lab = markup_label (str, 120, -1, 0.0, 0.5);
572 g_free (str);
573 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 50);
574 centry[i-11] = create_entry (G_CALLBACK(update_cross_parameter), 100, 15, FALSE, GINT_TO_POINTER(i-11));
575 update_entry_double (GTK_ENTRY(centry[i-11]), cross[tmp_fbody -> id][0][i-11]);
576 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, centry[i-11], FALSE, FALSE, 0);
577 add_box_child_start (GTK_ORIENTATION_VERTICAL, cross_vbox, hbox, FALSE, FALSE, 0);
578 }
579 if (tmp_fbody -> na[0] < 0)
580 {
582 }
583 else
584 {
586 }
587 }
588 }
589 else
590 {
591 hbox = create_hbox (0);
592 str = g_strdup_printf ("<i>Tabulated</i>");
593 lab = markup_label (str, 100, -1, 0.0, 0.5);
594 g_free (str);
595 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
596 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 0);
597 }
598 if (obj == 9 && tmp_field -> type >= CFF91 && tmp_field -> type <= COMPASS)
599 {
600 str = g_strdup_printf ("In %s, non-bonded interactions are evaluated using: \n%s\nTherefore the parameters provided by the force field are incompatible with the DL-POLY options.", field_acro[tmp_field -> type], get_this_vdw_string());
601 hbox = create_hbox (0);
602 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
603 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
604 g_free (str);
605 }
606 else if (obj == 9 && key == 0 && (tmp_field -> type <= CVFF_AUG || tmp_field -> type > COMPASS))
607 {
608 if (tmp_field -> type < CVFF)
609 {
610 str = g_strdup_printf ("In %s, 12-6 non-bonded interactions are evaluated using: \n%s\n<i><b>A</b></i> and <i><b>B</b></i>"
611 " are calculated using Ɛ<sub>i/j</sub> and r0<sub>i/j</sub> provided by the force field parameters.",
613 if (tmp_field -> type > AMBER99)
614 {
615 str = g_strdup_printf ("%s\nScaled 1-4 exclusion parameters, provided by the %s force field, are ignored.", str, field_acro[tmp_field -> type]);
616 }
617 }
618 else
619 {
620 str = g_strdup_printf ("In %s, 12-6 non-bonded interactions are evaluated using: \n%s\n<i><b>A</b></i> and <i><b>B</b></i>"
621 " are calculated using A<sub>i/j</sub> and B<sub>i/j</sub> provided by the force field parameters.",
623 }
624 hbox = create_hbox (0);
625 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
626 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
627 g_free (str);
628 }
629 else if ((obj == 3 || obj == 4) && tmp_field -> type > AMBER99 && tmp_field -> type < CVFF)
630 {
631 hbox = create_hbox (0);
632 str = g_strdup_printf ("Urey-Bradley terms provided by the %s force field are ignored.\n", field_acro[tmp_field -> type]);
633 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, markup_label (str, -1, -1, 0.5, 0.5), FALSE, FALSE, 50);
634 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, hbox, FALSE, FALSE, 10);
635 g_free (str);
636 }
637 }
638 return vbox;
639}
640
648gchar * field_str (int a)
649{
650 gchar * str = g_strdup_printf ("External field");
651 if (a > -1)
652 {
653 str = g_strdup_printf ("%s: <b>%s</b>", str, fnames[activef][15][a]);
654 }
655 return str;
656}
657
664{
665 gchar * text = "Are you sure to want to change the type of Tersoff potential ?\n"
666 "<i>Tersoff (ter)</i> and <i>KIHS (kihs)</i> forms cannot be mixed\n"
667 "Therefore this choice will affect <b>all</b> Tersoff potential(s)"
668 "Any previous parameters will be erased !";
669 if (num_body_d > 1)
670 {
671 return ask_yes_no ("Change Tersoff potential ?!", text, GTK_MESSAGE_QUESTION, field_assistant);
672 }
673 else
674 {
675 change_tersoff = TRUE;
676 return TRUE;
677 }
678}
679
687GtkWidget * param_prop_param_box (int pid)
688{
689 switch (pid)
690 {
691 case MOLIMIT-9:
692 return parameters_box (0, tmp_ftet -> key, fvars_teth[activef][tmp_ftet -> key], tmp_ftet -> val);
693 break;
694 case MOLIMIT-1:
695 return parameters_box (pid-6, tmp_fprop -> key, fvars_inversion[activef][tmp_fprop -> key], tmp_fprop -> val);
696 break;
697 case MOLIMIT:
698 return parameters_box (pid-6, tmp_fbody -> key, fvars_vdw[activef][tmp_fbody -> key], tmp_fbody -> val);
699 break;
700 case MOLIMIT+1:
701 return parameters_box (pid-6, tmp_fbody -> key, fvars_met[activef][tmp_fbody -> key], tmp_fbody -> val);
702 break;
703 case MOLIMIT+2:
704 return parameters_box (pid-6, tmp_fbody -> key, fvars_ters[activef][tmp_fbody -> key], tmp_fbody -> val);
705 break;
706 case MOLIMIT+3:
707 return parameters_box (pid-6, tmp_fbody -> key, fvars_tbd[activef][tmp_fbody -> key], tmp_fbody -> val);
708 break;
709 case MOLIMIT+4:
710 return parameters_box (pid-6, tmp_fbody -> key, fvars_fbd[activef][tmp_fbody -> key], tmp_fbody -> val);
711 break;
712 case SEXTERN:
713 return parameters_box (14, tmp_fext -> key, fvars_fext[activef][tmp_fext -> key], tmp_fext -> val);
714 break;
715 default:
716 switch ((pid-7)/2)
717 {
718 case 0:
719 return parameters_box (pid-6, tmp_fprop -> key, fvars_bond[activef][tmp_fprop -> key], tmp_fprop -> val);
720 break;
721 case 1:
722 return parameters_box (pid-6, tmp_fprop -> key, fvars_angle[activef][tmp_fprop -> key], tmp_fprop -> val);
723 break;
724 default:
725 return parameters_box (pid-6, tmp_fprop -> key, fvars_dihedral[activef][tmp_fprop -> key], tmp_fprop -> val);
726 break;
727 }
728 break;
729 }
730}
731
740G_MODULE_EXPORT void changed_field_key_combo (GtkComboBox * box, gpointer data)
741{
742 int i, j;
743 gboolean changeit = FALSE;
744 i = GPOINTER_TO_INT(data);
745 j = combo_get_active ((GtkWidget *)box);
746 if (i > 6 && i < MOLIMIT)
747 {
748 if (j != tmp_fprop -> key)
749 {
750 tmp_fprop -> key = j;
751 tmp_fprop -> val = NULL;
752 tmp_fprop -> val = allocfloat (fvalues[activef][i-6][j]);
753 changeit = TRUE;
754 }
755 }
756 else
757 {
758 switch (i)
759 {
760 case 6:
761 if (j != tmp_ftet -> key)
762 {
763 tmp_ftet -> key = j;
764 tmp_ftet -> val = NULL;
765 tmp_ftet -> val = allocfloat (fvalues[activef][0][j]);
766 changeit = TRUE;
767 }
768 break;
769 case SEXTERN:
770 if (j != tmp_fext -> key)
771 {
772 tmp_fext -> key = j;
773 gtk_label_set_text (GTK_LABEL(body_lab), field_str(tmp_fext -> key));
774 gtk_label_set_use_markup (GTK_LABEL(body_lab), TRUE);
775 tmp_fext -> val = NULL;
777 changeit = TRUE;
778 }
779 break;
780 default:
781 if (j != tmp_fbody -> key)
782 {
783 changeit = TRUE;
784 if (i == MOLIMIT+2) changeit = tersoff_question ();
785 if (changeit)
786 {
787 tmp_fbody -> key = j;
788 tmp_fbody -> val = NULL;
789 tmp_fbody -> val = allocfloat (fvalues[activef][i-6][j]);
790 if (i == MOLIMIT+2 && j == 0)
791 {
793 }
794 else if (j == 1 && cross != NULL)
795 {
796 g_free (cross);
797 cross = NULL;
798 }
799 }
800 else
801 {
802 combo_set_active ((GtkWidget *)box, tmp_fbody -> key);
803 }
804 }
805 break;
806 }
807 }
808 if (changeit)
809 {
810 if (ff_p_combo[0]) combo_set_active (ff_p_combo[0], 0);
811 if (ff_p_combo[1]) combo_set_active (ff_p_combo[1], 0);
814 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, param_box, p_box, FALSE, FALSE, 0);
816 }
817
818}
819
820#ifdef GTK4
829G_MODULE_EXPORT void visualize_it (GtkCheckButton * but, gpointer data)
830#else
839G_MODULE_EXPORT void visualize_it (GtkToggleButton * but, gpointer data)
840#endif
841{
842 int i, j;
843 i = GPOINTER_TO_INT (data);
844 j = 0;
845 toviz.c = button_get_status ((GtkWidget *)but);
846 if (i < MOLIMIT)
847 {
848 j = combo_get_active (combo_mol[i-1]);
850 }
851 if (is_moy)
852 {
853 visualize_object (i, row_id, j);
855 }
856 else
857 {
859 if (i < MOLIMIT)
860 {
862 tmp_fprop -> show = toviz.c;
863 }
864 }
867}
868
869#ifdef GTK4
878G_MODULE_EXPORT void select_it (GtkCheckButton * but, gpointer data)
879#else
888G_MODULE_EXPORT void select_it (GtkToggleButton * but, gpointer data)
889#endif
890{
891 int i, j;
892 i = GPOINTER_TO_INT (data);
893 toviz.c = button_get_status ((GtkWidget *)but);
894 if (i < MOLIMIT) j = combo_get_active (combo_mol[i-1]);
895 if (is_moy)
896 {
897 select_object (i, row_id, j);
898 }
899 else
900 {
901 tmp_fprop -> use = toviz.c;
902 }
903}
904
905extern ColRGBA init_color (int id, int numid);
906extern int active_sel;
907extern int a_ato;
908extern int ** sel_at;
909extern void run_select_atom_dialog (GtkDialog * select_dialog, gint response_id, gpointer data);
910GtkWidget * add_tree;
912
922G_MODULE_EXPORT void field_molecule_select_atom_id (GtkCellRendererToggle * cell_renderer, gchar * string_path, gpointer data)
923{
924 GtkTreeStore ** model = (GtkTreeStore **)data;
925 GtkTreeIter iter;
926 int h, i, j, k, l, m, n;
927 GtkTreePath * path = gtk_tree_path_new_from_string (string_path);
928 gtk_tree_model_get_iter (GTK_TREE_MODEL(* model), & iter, path);
929 gtk_tree_model_get (GTK_TREE_MODEL(* model), & iter, 0, & i, -1);
930 if (gtk_cell_renderer_toggle_get_active(cell_renderer))
931 {
932 toviz.c = 0;
933 a_ato --;
934 }
935 else
936 {
937 toviz.c = 1;
938 a_ato ++;
939 }
940 if (active_sel < 11)
941 {
942 sel_at[0][i-1] = toviz.c;
943 }
944 switch (active_sel)
945 {
946 case 0:
947 j = i-1;
948 break;
949 case 1:
950 j = i-1;
951 break;
952 case 2:
953 j = tmp_fshell -> id;
954 break;
955 case 3:
956 j = tmp_fshell -> id;
957 break;
958 case 4:
959 j = tmp_fcons -> id;
960 break;
961 case 5:
962 j = tmp_fcons -> id;
963 break;
964 case 6:
965 j = tmp_fpmf -> id;
966 break;
967 case 7:
968 j = tmp_fpmf -> id;
969 break;
970 case 8:
971 j = tmp_frig -> id;
972 break;
973 case 9:
974 j = tmp_ftet -> id;
975 break;
976 default:
977 j = tmp_fbody -> id;
978 break;
979 }
980 if (active_sel < 10)
981 {
982 for (k=0; k<tmp_fmol -> multi; k++)
983 {
984 l = tmp_fmol -> atoms_id[i-1][k].a;
985 m = tmp_fmol -> atoms_id[i-1][k].b;
986 n = get_active_atom (tmp_fmol -> id, l) -> list[m];
987 field_selection (n, toviz.c, toviz.c, i-1);
988 }
989 }
990 else
991 {
992 h = vdw_id = sel_at[0][i-1];
993 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
994 for (k=0; k<tmp_field -> nbody[0]; k++)
995 {
996 if (tmp_fbo -> id == h)
997 {
998 visualize_body (toviz.c, h, tmp_fbo);
999 break;
1000 }
1001 else if (tmp_fbo -> next != NULL)
1002 {
1003 tmp_fbo = tmp_fbo -> next;
1004 }
1005 }
1006 }
1008 j = (active_sel > 5 && active_sel < 8) ? 1 : 0;
1009 gtk_tree_store_set (* model, & iter, 3+j, toviz.c, -1);
1012}
1013
1022void select_atom_set_color (GtkCellRenderer * renderer, int i)
1023{
1024 set_renderer_color (i, renderer, init_color (i-1, num_field_objects));
1025}
1026
1038void select_atom_set_cmv (GtkTreeViewColumn * col, GtkCellRenderer * renderer, GtkTreeModel * mod, GtkTreeIter * iter, gpointer data)
1039{
1040 int h, i, j, k;
1041 gchar * str = NULL;
1042 gtk_tree_model_get (mod, iter, 0, & h, -1);
1043 if (active_sel < 11)
1044 {
1045 gtk_tree_model_get (mod, iter, 1, & i, -1);
1046 }
1047 else
1048 {
1049 i = ! h;
1050 }
1051 j = GPOINTER_TO_INT(data);
1052 switch (j)
1053 {
1054 case 0:
1055 gtk_cell_renderer_set_visible (renderer, ! i);
1056 break;
1057 case 1:
1058 if (active_sel > 10)
1059 {
1060 gtk_tree_model_get (mod, iter, 1, & str, -1);
1061 g_object_set (renderer, "markup", str, NULL, NULL);
1062 g_free (str);
1063 i = h;
1064 }
1065 gtk_cell_renderer_set_visible (renderer, i);
1066 break;
1067 case 2:
1068 gtk_tree_model_get (mod, iter, 2, & str, -1);
1069 g_object_set (renderer, "markup", str, NULL, NULL);
1070 g_free (str);
1071 gtk_cell_renderer_set_visible (renderer, i);
1072 break;
1073 case 3:
1074 gtk_cell_renderer_set_visible (renderer, ! i);
1075 break;
1076 case 4:
1077 if ((active_sel > 1 && active_sel < 6) || active_sel > 8)
1078 {
1079 if (active_sel > 10)
1080 {
1081 gtk_tree_model_get (mod, iter, 3, & k, -1);
1082 }
1083 else
1084 {
1085 k = sel_at[0][h-1];
1086 }
1087 if (k || ! a_ato)
1088 {
1089 gtk_cell_renderer_set_visible (renderer, TRUE);
1090 }
1091 else
1092 {
1093 gtk_cell_renderer_set_visible (renderer, ! a_ato);
1094 }
1095 }
1096 else
1097 {
1098 gtk_cell_renderer_set_visible (renderer, ! i);
1099 }
1100 break;
1101 }
1102 if (active_sel < 2 && j < 4)
1103 {
1104 for (i=0; i<tmp_fat -> num/tmp_fmol -> multi; i++)
1105 {
1106 if (sel_at[0][i]+1 == abs(h)) break;
1107 }
1108 if (sel_at[1][i])
1109 {
1110 select_atom_set_color (renderer, sel_at[0][i]+1);
1111 }
1112 else
1113 {
1114 select_atom_set_color (renderer, sel_at[1][i]);
1115 }
1116 }
1117 else if (j < 4)
1118 {
1119 if (h < 0) h = -h;
1120 if (active_sel < 11)
1121 {
1122 k = (sel_at[0][h-1]) ? h : 0;
1123 }
1124 else
1125 {
1126 gtk_tree_model_get (mod, iter, 3, & k, -1);
1127 }
1128 select_atom_set_color (renderer, k);
1129 }
1130}
1131
1132float * val_at;
1133
1134/*
1135* G_MODULE_EXPORT void edit_unit_weight (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data)
1136
1137 \brief on edit unit weight callback
1138
1139 \param cell the GtkCellRendererToggle sending the signal
1140 \param string_path the path in the tree store
1141* gchar
1142 \param data the associated data pointer
1143*/
1144G_MODULE_EXPORT void edit_unit_weight (GtkCellRendererText * cell, gchar * path_string, gchar * new_text, gpointer data)
1145{
1146 GtkTreeStore ** model = (GtkTreeStore **)data;
1147 GtkTreeIter iter;
1148 int i;
1149 GtkTreePath * path = gtk_tree_path_new_from_string (path_string);
1150 gtk_tree_model_get_iter (GTK_TREE_MODEL(* model), & iter, path);
1151 gtk_tree_model_get (GTK_TREE_MODEL(* model), & iter, 0, & i, -1);
1152 val_at[i] = string_to_double ((gpointer)new_text);
1153}
1154
1163G_MODULE_EXPORT void select_atom_id_from_fied_molecule (GtkButton * but, gpointer data)
1164{
1165 int i, j, k, l, m, n, o, p, q;
1166 GtkTreeIter id_level;
1167 GtkTreeIter atom_level;
1168 GtkTreeViewColumn * ato_col[5];
1169 GtkCellRenderer * ato_cell[5];
1170 gchar * ato_title[5] = {"Atom Id", "Fragment", "Atom", "Weight (1)", "Viz.3D & Select"};
1171 gchar * nbd_title[5] = {"Atom Id", "Field atom", "Field molecule(s)", " ", "Viz.3D & Select"};
1172 gchar * ctype[5]={"text", "text", "text", "text", "active"};
1173 GType col_type[2][5] = {{G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_BOOLEAN, G_TYPE_FLOAT},
1174 {G_TYPE_INT, G_TYPE_INT, G_TYPE_STRING, G_TYPE_FLOAT, G_TYPE_BOOLEAN}};
1175 GType cbl_type[4] = {G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_BOOLEAN};
1176 field_object = 1;
1177 active_sel = GPOINTER_TO_INT (data);
1178 gboolean add;
1179 gchar * str;
1180 q = (active_sel > 5 && active_sel < 8) ? 1 : 0;
1181 switch (active_sel)
1182 {
1183 case 0:
1184 str = g_strdup_printf ("Please select the new atom(s)");
1185 o = -1;
1186 p = -1;
1187 break;
1188 case 1:
1189 str = g_strdup_printf ("Please select the atom(s) to freeze / unfreeze");
1190 o = -1;
1191 p = -1;
1192 break;
1193 case 2:
1194 str = g_strdup_printf ("Please select the core atom");
1195 o = tmp_fshell -> ia[0]-1;
1196 p = tmp_fshell -> ia[1]-1;
1197 break;
1198 case 3:
1199 str = g_strdup_printf ("Please select the atom(s) to shell");
1200 o = tmp_fshell -> ia[1]-1;
1201 p = tmp_fshell -> ia[0]-1;
1202 break;
1203 case 4:
1204 str = g_strdup_printf ("Please select the first atom");
1205 o = tmp_fcons -> ia[0]-1;
1206 p = tmp_fcons -> ia[1]-1;
1207 break;
1208 case 5:
1209 str = g_strdup_printf ("Please select the second atom");
1210 o = tmp_fcons -> ia[1]-1;
1211 p = tmp_fcons -> ia[0]-1;
1212 break;
1213 case 6:
1214 str = g_strdup_printf ("Please select the atom(s) in the first unit");
1215 break;
1216 case 7:
1217 str = g_strdup_printf ("Please select the atom(s) in the second unit");
1218 break;
1219 case 8:
1220 str = g_strdup_printf ("Please select the atom(s) in the rigid unit");
1221 p = -1;
1222 break;
1223 case 9:
1224 str = g_strdup_printf ("Please select the tethered atom");
1225 o = tmp_ftet -> num-1;
1226 p = -1;
1227 break;
1228 case 11:
1229 if (tmp_fbody -> bd == 2)
1230 {
1231 str = g_strdup_printf ("Please select the type of field atom");
1232 }
1233 else
1234 {
1235 str = g_strdup_printf ("Please select the first type of field atom");
1236 }
1237 break;
1238 case 12:
1239 str = g_strdup_printf ("Please select the second type of field atom");
1240 break;
1241 case 13:
1242 str = g_strdup_printf ("Please select the third type of field atom");
1243 break;
1244 case 14:
1245 str = g_strdup_printf ("Please select the fourth type of field atom");
1246 break;
1247 }
1248 GtkWidget * amol = dialogmodal (str, GTK_WINDOW(field_assistant));
1249 g_free (str);
1250 gtk_dialog_add_button (GTK_DIALOG(amol), "Apply", GTK_RESPONSE_APPLY);
1251 a_ato = 0;
1252 GtkTreeStore * add_model;
1253 if (active_sel < 11)
1254 {
1255 add_model = gtk_tree_store_newv (4+q, col_type[q]);
1256 }
1257 else
1258 {
1259 add_model = gtk_tree_store_newv (4, cbl_type);
1260 }
1261 add_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(add_model));
1262 if (active_sel < 11)
1263 {
1264 num_field_objects = tmp_fmol -> mol -> natoms;
1265 }
1266
1267 for (i=0; i<4+q; i++)
1268 {
1269 k = i;
1270 if (i < 3+q)
1271 {
1272 ato_cell[i] = gtk_cell_renderer_text_new ();
1273 }
1274 else
1275 {
1276 if (! q) k ++;
1277 ato_cell[i] = gtk_cell_renderer_toggle_new ();
1278 if (active_sel > 1) gtk_cell_renderer_toggle_set_radio (GTK_CELL_RENDERER_TOGGLE(ato_cell[i]), TRUE);
1279 g_signal_connect (G_OBJECT(ato_cell[i]), "toggled", G_CALLBACK(field_molecule_select_atom_id), & add_model);
1280 }
1281 if (active_sel < 11)
1282 {
1283 ato_col[i] = gtk_tree_view_column_new_with_attributes (ato_title[k], ato_cell[i], ctype[k], i, NULL);
1284 }
1285 else
1286 {
1287 ato_col[i] = gtk_tree_view_column_new_with_attributes (nbd_title[k], ato_cell[i], ctype[k], i, NULL);
1288 }
1289 gtk_tree_view_append_column (GTK_TREE_VIEW(add_tree), ato_col[i]);
1290 gtk_tree_view_column_set_alignment (ato_col[i], 0.5);
1291 gtk_tree_view_column_set_cell_data_func (ato_col[i], ato_cell[i], select_atom_set_cmv, GINT_TO_POINTER(k), NULL);
1292 if (q && i == 3)
1293 {
1294 g_object_set (ato_cell[i], "editable", TRUE, NULL);
1295 g_signal_connect (G_OBJECT(ato_cell[i]), "edited", G_CALLBACK(edit_unit_weight), & add_model);
1296 }
1297 }
1298 // Clean 3D viz
1300 // fill model
1301 if (active_sel < 2)
1302 {
1303 sel_at = allocdint(2, tmp_fat -> num/tmp_fmol -> multi);
1304 }
1305 else if (active_sel < 11)
1306 {
1307 sel_at = allocdint(2, tmp_fmol -> mol -> natoms);
1308 }
1309 else
1310 {
1311 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
1312 k = 0;
1313 for (i=0; i<tmp_field -> nbody[0]; i++)
1314 {
1315 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1316 get_active_atom (tmp_fbo -> ma[1][0], tmp_fbo -> a[1][0]) -> name) == 0) k ++;
1317 if (tmp_fbo -> next != NULL) tmp_fbo = tmp_fbo -> next;
1318 }
1319 sel_at = allocdint(1, k);
1321 }
1322
1323 if (active_sel < 2)
1324 {
1325 l = 0;
1326 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1327 {
1328 if (tmp_fmol -> atoms_id[i][0].a == tmp_fat -> id)
1329 {
1330 j = tmp_fmol -> atoms_id[i][0].b;
1331 k = tmp_fat -> list_id[j];
1332 sel_at[0][l] = k;
1333 if (active_sel)
1334 {
1335 sel_at[1][l] = tmp_fat -> frozen_id[j];
1336 }
1337 else
1338 {
1339 sel_at[1][l] = 0;
1340 }
1341 l ++;
1342 }
1343 }
1344 for (i=0; i<tmp_fat -> num/tmp_fmol -> multi; i++)
1345 {
1346 gtk_tree_store_append (add_model, & id_level, NULL);
1347 gtk_tree_store_set (add_model, & id_level, 0, sel_at[0][i]+1, 1, 0, 3, 0, -1);
1348 if (sel_at[1][i])
1349 {
1350 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[3]),
1351 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1352 & add_model);
1353 }
1354 for (j=0; j< tmp_fmol -> multi; j++)
1355 {
1356 gtk_tree_store_append (add_model, & atom_level, & id_level);
1357 k = sel_at[0][i];
1358 l = tmp_fmol -> atoms_id[k][j].b;
1359 m = tmp_fat -> list[l];
1360 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), m+1);
1361 gtk_tree_store_set (add_model, & atom_level, 0, -(sel_at[0][i]+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1362 g_free (str);
1363 }
1364 }
1365 }
1366 else if (active_sel < 4)
1367 {
1368 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1369 {
1370 if (i != p)
1371 {
1372 gtk_tree_store_append (add_model, & id_level, NULL);
1373 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, 0, -1);
1374 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1375 for (j=0; j< tmp_fmol -> multi; j++)
1376 {
1377 gtk_tree_store_append (add_model, & atom_level, & id_level);
1378 k = tmp_fat -> list[tmp_fmol -> atoms_id[i][j].b];
1379 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), k+1);
1380 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1381 g_free (str);
1382 }
1383 }
1384 }
1385 }
1386 else if (active_sel < 6 || (active_sel > 7 && active_sel < 11))
1387 {
1388 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1389 {
1390 if (i != p)
1391 {
1392 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1393 gtk_tree_store_append (add_model, & id_level, NULL);
1394 if (active_sel < 6 || active_sel == 9)
1395 {
1396 if (i == o)
1397 {
1398 k = 1;
1399 }
1400 else
1401 {
1402 k = 0;
1403 }
1404 }
1405 else
1406 {
1407 k = 0;
1408 if (tmp_frig -> num > 0)
1409 {
1410 for (j=0; j<tmp_frig -> num; j++)
1411 {
1412 if (i == tmp_frig -> list[j])
1413 {
1414 k = 1;
1415 break;
1416 }
1417 }
1418 }
1419 }
1420 sel_at[0][i] = k;
1421 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, 0, -1);
1422 if (sel_at[0][i])
1423 {
1424 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[3]),
1425 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1426 & add_model);
1427 }
1428 for (j=0; j< tmp_fmol -> multi; j++)
1429 {
1430 gtk_tree_store_append (add_model, & atom_level, & id_level);
1431 l = tmp_fat -> list[tmp_fmol -> atoms_id[i][j].b];
1432 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), l+1);
1433 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[j]+1, 2, str, -1);
1434 g_free (str);
1435 }
1436 }
1437 }
1438 }
1439 else if (active_sel > 10)
1440 {
1441 m = active_sel-11;
1442 field_nth_body * tmp_fbo = tmp_field -> first_body[0];
1443 k = 0;
1444 for (i=0; i<tmp_field -> nbody[0]; i++)
1445 {
1446 // need to find the atoms name
1447 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1448 get_active_atom (tmp_fbo -> ma[1][0], tmp_fbo -> a[1][0]) -> name) == 0)
1449 {
1450 add = TRUE;
1451 for (j=0; j < body_at(tmp_fbody -> bd); j++)
1452 {
1453 if (j != m && tmp_fbody -> na[j] > -1)
1454 {
1455 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1456 get_active_atom (tmp_fbody -> ma[j][0], tmp_fbody -> a[j][0]) -> name) == 0) add = FALSE;
1457 }
1458 }
1459 if (add)
1460 {
1461 gtk_tree_store_append (add_model, & id_level, NULL);
1462 l = 0;
1463 if (tmp_fbody -> na[m] > -1)
1464 {
1465 if (g_strcmp0 (get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name,
1466 get_active_atom (tmp_fbody -> ma[m][0], tmp_fbody -> a[m][0]) -> name) == 0)
1467 {
1468 l = 1;
1469 vdw_id = tmp_fbo -> id;
1470 a_ato = 1;
1471 }
1472 }
1473 gtk_tree_store_set (add_model, & id_level, 0, k+1, 1,
1474 exact_name(get_active_atom (tmp_fbo -> ma[0][0], tmp_fbo -> a[0][0]) -> name), 3, l, -1);
1475 sel_at[0][k] = tmp_fbo -> id;
1476 for (j=0; j<tmp_fbo -> na[0]; j++)
1477 {
1478 gtk_tree_store_append (add_model, & atom_level, & id_level);
1479 gtk_tree_store_set (add_model, & atom_level, 0, 0, 2, get_active_field_molecule(tmp_fbo -> ma[0][j]) -> name, 3, 0, -1);
1480 }
1481 }
1482 k ++;
1483 }
1484 if (tmp_fbo -> next != NULL) tmp_fbo = tmp_fbo -> next;
1485 }
1486 }
1487 else
1488 {
1489 val_at = allocfloat (tmp_fmol -> mol -> natoms);
1490 if (active_sel == 5)
1491 {
1492 k = 1;
1493 m = 0;
1494 }
1495 else
1496 {
1497 k = 0;
1498 m = 1;
1499 }
1500 for (i=0; i<tmp_fmol -> mol -> natoms; i++)
1501 {
1502 add = TRUE;
1503 if (tmp_fpmf -> num[k] > 0)
1504 {
1505 for (l=0; l<tmp_fpmf -> num[k]; l++)
1506 {
1507 if (i == tmp_fpmf -> list[k][l])
1508 {
1509 add = FALSE;
1510 break;
1511 }
1512 }
1513 }
1514 if (add)
1515 {
1516 tmp_fat = get_active_atom (tmp_fmol -> id, tmp_fmol -> atoms_id[i][0].a);
1517 gtk_tree_store_append (add_model, & id_level, NULL);
1518 n = 0;
1519 if (tmp_fpmf -> num[m] > 0)
1520 {
1521 for (l=0; l<tmp_fpmf -> num[m]; l++)
1522 {
1523 if (i == tmp_fpmf -> list[m][l])
1524 {
1525 n = 1;
1526 break;
1527 }
1528 }
1529 }
1530 val_at[i] = tmp_fat -> mass;
1531 sel_at[0][i] = n;
1532 gtk_tree_store_set (add_model, & id_level, 0, i+1, 1, 0, 3, val_at[i], 4, 0, -1);
1533 if (sel_at[0][i])
1534 {
1535 field_molecule_select_atom_id (GTK_CELL_RENDERER_TOGGLE(ato_cell[4]),
1536 gtk_tree_path_to_string(gtk_tree_model_get_path(GTK_TREE_MODEL(add_model), & id_level)),
1537 & add_model);
1538 }
1539 for (l=0; l< tmp_fmol -> multi; l++)
1540 {
1541 gtk_tree_store_append (add_model, & atom_level, & id_level);
1542 n = tmp_fat -> list[tmp_fmol -> atoms_id[i][l].b];
1543 str = g_strdup_printf ("%s<sub>%d</sub>", exact_name(tmp_proj -> chemistry -> label[tmp_fat -> sp]), n+1);
1544 gtk_tree_store_set (add_model, & atom_level, 0, -(i+1), 1, tmp_fmol -> fragments[l]+1, 2, str, -1);
1545 g_free (str);
1546 }
1547 }
1548 }
1549 }
1550 g_object_unref (add_model);
1551
1552 if (active_sel < 2)
1553 {
1554 j = tmp_fat -> num/tmp_fmol -> multi;
1555 }
1556 else
1557 {
1559 }
1560 i = ((j+1)*37 < 500) ? (j+1)*37 : 500;
1561 if (active_sel > 10) q = 1;
1562 GtkWidget * vbox = dialog_get_content_area (amol);
1563 GtkWidget * scrollsets = create_scroll (vbox, 320+q*100, i, GTK_SHADOW_ETCHED_IN);
1565
1566 if (q && active_sel < 11)
1567 {
1568 str = g_strdup_printf (" <b>(1)</b> if all 0.0 then atomic weight(s) will be used by DL-POLY");
1569 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.0, 0.5), FALSE, FALSE, 0);
1570 g_free (str);
1571 }
1572 if (active_sel < 2)
1573 {
1574 str = g_strdup_printf ("The atom(s) above will be described\n"
1575 "in the force field using the parameters\n"
1576 "of the <b>%s</b> field atom.\n", tmp_fat -> name);
1577 add_box_child_start (GTK_ORIENTATION_VERTICAL, vbox, markup_label(str, -1, -1, 0.5, 0.5), FALSE, FALSE, 0);
1578 g_free (str);
1579 }
1580 show_the_widgets (amol);
1581 switch (active_sel)
1582 {
1583 case 0:
1584 run_this_gtk_dialog (amol, G_CALLBACK(run_add_atom_dialog), NULL);
1585 break;
1586 default:
1587 run_this_gtk_dialog (amol, G_CALLBACK(run_select_atom_dialog), GINT_TO_POINTER(active_sel));
1588 if (active_sel == 1)
1589 {
1590 str = g_strdup_printf ("%d atom(s)", tmp_fat -> frozen);
1591 if (but) gtk_button_set_label (but, str);
1592 }
1593 break;
1594 }
1595 g_free (sel_at);
1596 if (q && active_sel < 11) g_free (val_at);
1597}
1598
1599GtkWidget * av_lgt;
1600
1608void update_field_dist (float v)
1609{
1610 gchar * str;
1611 if (v < 0.0)
1612 {
1613 str = g_strdup_printf (" ");
1614 }
1615 else
1616 {
1617 str = g_strdup_printf ("<b>%8.3f</b>", v);
1618 }
1619 gtk_label_set_text (GTK_LABEL(av_lgt), str);
1620 gtk_label_set_use_markup (GTK_LABEL(av_lgt), TRUE);
1621}
1622
1630gchar * body_str (int a)
1631{
1632 int i, j;
1633 j = body_at (a);
1634 gchar * str = g_strdup_printf ("%s <b>", felemts[a+MOLIMIT+1]);
1635 for (i=0; i<j; i++)
1636 {
1637 if (tmp_fbody -> na[i] > -1)
1638 {
1639 str = g_strdup_printf ("%s%s", str, get_active_atom (tmp_fbody -> ma[i][0], tmp_fbody -> a[i][0]) -> name);
1640 }
1641 if (i < j-1 && j > 1) str = g_strdup_printf ("%s - ", str);
1642 }
1643 str = g_strdup_printf ("%s</b>", str);
1644 return str;
1645}
1646
1655G_MODULE_EXPORT void selection_button (GtkButton * but, gpointer data)
1656{
1658 int i, j, k, l, m, n, o, p, q, r;
1659 i = GPOINTER_TO_INT(data);
1660 gchar * stra = NULL;
1661 gchar * strb = NULL;
1662 if (i == 2 || i == 3)
1663 {
1664 j=i-2;
1665 if (! tmp_fshell -> ia[j])
1666 {
1667 stra = g_strdup_printf ("Not picked yet !");
1668 strb = g_strdup_printf (DELETEB);
1669 }
1670 else
1671 {
1672 k = tmp_fshell -> ia[j]-1;
1673 l = tmp_fmol -> atoms_id[k][0].a;
1674 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, l) -> sp]), tmp_fshell -> ia[j]);
1675 strb = g_strdup_printf (APPLY);
1676 }
1677 }
1678 else if (i == 4 || i == 5)
1679 {
1680 j=i-4;
1681 if (! tmp_fcons -> ia[j])
1682 {
1683 stra = g_strdup_printf ("Not picked yet !");
1684 strb = g_strdup_printf (DELETEB);
1685 }
1686 else
1687 {
1688 k = tmp_fcons -> ia[j] - 1;
1689 l = tmp_fmol -> atoms_id[k][0].a;
1690 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, l) -> sp]), tmp_fcons -> ia[j]);
1691 strb = g_strdup_printf (APPLY);
1692 }
1693 }
1694 else if (i == 6 || i == 7)
1695 {
1696 j=i-6;
1697 if (! tmp_fpmf -> num[j])
1698 {
1699 stra = g_strdup_printf ("Not picked yet !");
1700 strb = g_strdup_printf (DELETEB);
1701 }
1702 else
1703 {
1704 stra = g_strdup_printf ("%d atom(s)", tmp_fpmf -> num[j]);
1705 strb = g_strdup_printf (APPLY);
1706 }
1707 }
1708 else if (i == 8)
1709 {
1710 j=0;
1711 if (! tmp_frig -> num)
1712 {
1713 stra = g_strdup_printf ("Not picked yet !");
1714 strb = g_strdup_printf (DELETEB);
1715 }
1716 else
1717 {
1718 stra = g_strdup_printf ("%d atom(s)", tmp_frig -> num);
1719 strb = g_strdup_printf (APPLY);
1720 }
1721 }
1722 else if (i == 9)
1723 {
1724 j=0;
1725 if (! tmp_ftet -> num)
1726 {
1727 stra = g_strdup_printf ("Not picked yet !");
1728 strb = g_strdup_printf (DELETEB);
1729 }
1730 else
1731 {
1732 k = tmp_fmol -> atoms_id[tmp_ftet -> num - 1][0].a;
1733 stra = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (tmp_fmol -> id, k) -> sp]), tmp_ftet -> num);
1734 strb = g_strdup_printf (APPLY);
1735 }
1736 }
1737 else if (i == 11 || i == 12 || i == 13 || i == 14)
1738 {
1739 j=i-11;
1740 if (tmp_fbody -> na[j] < 0)
1741 {
1742 stra = g_strdup_printf ("Not picked yet !");
1743 strb = g_strdup_printf (DELETEB);
1744 }
1745 else
1746 {
1747 stra = g_strdup_printf ("%s", exact_name(get_active_atom (tmp_fbody -> ma[j][0]-1, tmp_fbody -> a[j][0]) -> name));
1748 strb = g_strdup_printf (APPLY);
1749 }
1750 if (tmp_fbody -> bd == 2)
1751 {
1754 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, cross_hbox, cross_box, FALSE, FALSE, 0);
1756 }
1757 if (tmp_fbody -> na[j] < 0)
1758 {
1760 }
1761 else
1762 {
1765 }
1766 gtk_label_set_text (GTK_LABEL(body_lab), body_str (tmp_fbody -> bd));
1767 gtk_label_set_use_markup (GTK_LABEL(body_lab), TRUE);
1768 }
1770 g_free (strb);
1771 if (i == 4 || i == 5)
1772 {
1773 if (tmp_fcons -> ia[0] && tmp_fcons -> ia[1])
1774 {
1775 // update_distance
1776 tmp_fcons -> av = 0.0;
1777 for (k=0; k<tmp_fmol -> multi; k++)
1778 {
1779 l = tmp_fmol -> atoms_id[tmp_fcons -> ia[0]-1][k].a;
1780 m = tmp_fmol -> atoms_id[tmp_fcons -> ia[0]-1][k].b;
1781 n = get_active_atom (tmp_fmol -> id, l) -> list[m];
1782 l = tmp_fmol -> atoms_id[tmp_fcons -> ia[1]-1][k].a;
1783 m = tmp_fmol -> atoms_id[tmp_fcons -> ia[1]-1][k].b;
1784 o = get_active_atom (tmp_fmol -> id, l) -> list[m];
1785 tmp_fcons -> av += distance_3d (& tmp_proj -> cell, 0, & tmp_proj -> atoms[0][n], & tmp_proj -> atoms[0][o]).length;
1786 }
1787 tmp_fcons -> av /= tmp_fmol -> multi;
1788 }
1790 }
1791 else if (i == 6 || i == 7)
1792 {
1793 if (tmp_fpmf -> num[0] > 0 && tmp_fpmf -> num[1] > 0)
1794 {
1795 atom at[2][tmp_fmol -> multi];
1796 float ma[2][tmp_fmol -> multi];
1797 gboolean all_zero = TRUE;
1798 float v;
1799 for (k=0; k<2; k++)
1800 {
1801 for (l=0; l<tmp_fpmf -> num[k]; l++)
1802 {
1803 if (tmp_fpmf -> weight[k][l] != 0.0)
1804 {
1805 all_zero = FALSE;
1806 break;
1807 }
1808 }
1809 if (! all_zero) break;
1810 }
1811 for (k=0; k<2; k++)
1812 {
1813 for (l=0; l<tmp_fmol -> multi; l++)
1814 {
1815 ma[k][l] = 0.0;
1816 at[k][l].x = 0.0;
1817 at[k][l].y = 0.0;
1818 at[k][l].z = 0.0;
1819 }
1820 }
1821 for (k=0; k<2; k++)
1822 {
1823 for (l=0; l<tmp_fpmf -> num[k]; l++)
1824 {
1825 m = tmp_fpmf -> list[k][l];
1826 for (n=0; n<tmp_fmol -> multi; n++)
1827 {
1828 o = tmp_fmol -> atoms_id[m][n].a;
1829 p = tmp_fmol -> atoms_id[m][n].b;
1830 q = get_active_atom (tmp_fmol -> id, o) -> list[p];
1831 if (all_zero)
1832 {
1833 r = tmp_proj -> atoms[0][q].sp;
1834 v = tmp_proj -> chemistry -> chem_prop[CHEM_M][r];
1835 }
1836 else
1837 {
1838 v = tmp_fpmf -> weight[k][l];
1839 }
1840 at[k][n].x += v * tmp_proj -> atoms[0][q].x;
1841 at[k][n].y += v * tmp_proj -> atoms[0][q].y;
1842 at[k][n].z += v * tmp_proj -> atoms[0][q].z;
1843 ma[k][n] += v;
1844 }
1845 }
1846 }
1847 v = 0.0;
1848 for (n=0; n<tmp_fmol -> multi; n++)
1849 {
1850 for (k=0; k<2; k++)
1851 {
1852 at[k][n].x /= ma[k][n];
1853 at[k][n].y /= ma[k][n];
1854 at[k][n].z /= ma[k][n];
1855 }
1856 v += distance_3d (& tmp_proj -> cell, 0, & at[0][n], & at[1][n]).length;
1857 }
1858 tmp_fpmf -> av = v / tmp_fmol -> multi;
1859 }
1861 }
1862 gtk_button_set_label (but, stra);
1863 gtk_widget_set_size_request ((GtkWidget *)but, 150, -1);
1864 g_free (stra);
1865}
1866
1875G_MODULE_EXPORT void changed_atom_combo (GtkComboBox * box, gpointer data)
1876{
1877 int i, j, k;
1878 i = GPOINTER_TO_INT(data);
1879 j = combo_get_active ((GtkWidget *)box);
1880 switch (i)
1881 {
1882 case 0:
1883 widget_set_sensitive (afftype, (j) ? TRUE : FALSE);
1884 k = -1;
1885 if (tmp_fat -> afid > -1)
1886 {
1887 for (k=0; k<atoms_id[tmp_fat -> sp]; k++)
1888 {
1889 if (atoms_id_list[tmp_fat -> sp][k] == tmp_fat -> afid) break;
1890 }
1891 }
1893 if (j)
1894 {
1895 tmp_fat -> mass =(tmp_fat -> afid < 0) ? tmp_proj -> chemistry -> chem_prop[CHEM_M][tmp_fat -> sp] : get_force_field_atom_mass (tmp_fat -> sp, tmp_fat -> afid);
1896 }
1897 else
1898 {
1899 tmp_fat -> mass = tmp_proj -> chemistry -> chem_prop[CHEM_M][tmp_fat -> sp];
1900 }
1901 break;
1902 case 1:
1903 if (j > 0)
1904 {
1905 tmp_fat -> afid = atoms_id_list[tmp_fat -> sp][j - 1];
1906 }
1907 else
1908 {
1909 tmp_fat -> afid = - 1;
1910 }
1911 tmp_fat -> mass = get_force_field_atom_mass (tmp_fat -> sp, j-1);
1913 break;
1914 }
1915}
1916
1926gchar * get_body_element_name (field_nth_body * body, int aid, int nbd)
1927{
1928 int i, j;
1929 i = body -> ma[aid][0];
1930 if (! nbd)
1931 {
1932 return g_strdup_printf ("%s", get_active_atom (i, body -> a[aid][0]) -> name);
1933 }
1934 else
1935 {
1936 j = get_active_shell (i, body -> a[aid][0]-nbd+1) -> ia[0];
1937 return g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1938 }
1939}
1940
1952gboolean body_identicals (field_nth_body * body, int nbd, int * na, int ** ma, int ** ba)
1953{
1954 gchar * stra, * strb, * strc, * strd;
1955 int i, j;
1956 stra = get_body_element_name (body, 0, 0);
1957 strb = get_body_element_name (body, 1, 0);
1958 i = ma[0][0];
1959 if (ba[0][0] < nbd)
1960 {
1961 strc = g_strdup_printf ("%s", get_active_atom (i, ba[0][0]) -> name);
1962 }
1963 else
1964 {
1965 j = get_active_shell (i, ba[0][0]-nbd) -> ia[0];
1966 strc = g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1967 }
1968 i = ma[1][0];
1969 if (ba[1][0] < nbd)
1970 {
1971 strd = g_strdup_printf ("%s", get_active_atom (i, ba[1][0]) -> name);
1972 }
1973 else
1974 {
1975 j = get_active_shell (i, ba[1][0]-nbd) -> ia[0];
1976 strd = g_strdup_printf ("%s_sh", get_active_atom (i, j) -> name);
1977 }
1978 gboolean res = FALSE;
1979 if (g_strcmp0(stra, strc) == 0 && g_strcmp0(strb, strd) == 0) res = TRUE;
1980 if (g_strcmp0(stra, strd) == 0 && g_strcmp0(strb, strc) == 0) res = TRUE;
1981 // g_debug ("stra= %s, strb= %s, strc= %s, strd= %s:: res= %d", stra, strb, strc, strd, res);
1982 g_free (stra);
1983 g_free (strb);
1984 g_free (strc);
1985 g_free (strd);
1986 return res;
1987}
1988
1995{
1996 int i;
1997 field_molecule * molff;
1998 field_shell * shellff;
1999 molff = tmp_field -> first_molecule;
2000 i = 0;
2001 while (molff)
2002 {
2003 i += molff -> atoms;
2004 shellff = molff -> first_shell;
2005 while (shellff)
2006 {
2007 if (shellff -> use && shellff -> vdw && shellff -> ia[0] > -1) i ++;
2008 shellff = shellff -> next;
2009 }
2010 molff = molff -> next;
2011 }
2012 return i;
2013}
2014
2022void adjust_vdw_interactions (gboolean add_shell)
2023{
2024 int i, j, k, l, m, n;
2025 field_molecule * molff;
2026 field_atom* atff;
2027 field_shell * shellff;
2028 field_nth_body * bodyff;
2029
2030 i = get_num_vdw_max ();
2031 m = i * (i+1) / 2;
2032 n = (add_shell) ? i * (i-1) / 2 : (i+1) * (i+2) / 2;
2033 bodyff = get_active_body (0, 0);
2034 while (bodyff)
2035 {
2036 for (j=0; j<2; j++)
2037 {
2038 k = bodyff -> ma[j][0];
2039 if (bodyff -> a[j][0] >= n)
2040 {
2041 bodyff -> a[j][0] -= n;
2042 bodyff -> a[j][0] += m;
2043 }
2044 }
2045 bodyff = bodyff -> next;
2046 }
2047 if (add_shell)
2048 {
2049 gboolean add_vdw;
2050 gchar * str;
2051 gchar ** to_be_vdw = g_malloc (i*sizeof*to_be_vdw);
2052 int * vdw_mlist = allocint (i);
2053 int ** vdw_aids = allocdint (i,i);
2054 int ** vdw_mids = allocdint (i,i);
2055 int vdw_na[2];
2056 int * vdw_a[2], * vdw_ma[2];
2057 int nbd = m;
2058 molff = tmp_field -> first_molecule;
2059 l = 0;
2060 while (molff)
2061 {
2062 atff = molff -> first_atom;
2063 while (atff)
2064 {
2065 add_vdw = TRUE;
2066 for (k=0; k<l; k++)
2067 {
2068 if (g_strcmp0 (to_be_vdw[k], atff -> name) == 0)
2069 {
2070 add_vdw = FALSE;
2071 vdw_mlist[k] ++;
2072 vdw_mids[k][vdw_mlist[k]] = molff -> id;
2073 vdw_aids[k][vdw_mlist[k]] = atff -> id;
2074 break;
2075 }
2076 }
2077 if (add_vdw)
2078 {
2079 to_be_vdw[k] = g_strdup_printf ("%s", atff -> name);
2080 vdw_mids[k][0] = molff -> id;
2081 vdw_aids[k][0] = atff -> id;
2082 l ++;
2083 }
2084 atff = atff -> next;
2085 }
2086 shellff = molff -> first_shell;
2087 while (shellff)
2088 {
2089 if (shellff -> use && shellff -> vdw && shellff -> ia[0] > -1)
2090 {
2091 add_vdw = TRUE;
2092 atff = get_active_atom (molff -> id, shellff -> ia[0]);
2093 str = g_strdup_printf ("%s_sh", atff -> name);
2094 for (k=0; k<l; k++)
2095 {
2096 if (g_strcmp0 (to_be_vdw[k], str) == 0)
2097 {
2098 add_vdw = FALSE;
2099 vdw_mlist[k] ++;
2100 vdw_mids[k][vdw_mlist[k]] = molff -> id;
2101 vdw_aids[k][vdw_mlist[k]] = shellff -> id + nbd;
2102 break;
2103 }
2104 }
2105 if (add_vdw)
2106 {
2107 to_be_vdw[k] = g_strdup_printf ("%s", str);
2108 vdw_mids[k][0] = molff -> id;
2109 vdw_aids[k][0] = shellff -> id + nbd;
2110 l ++;
2111 }
2112 g_free (str);
2113 }
2114 shellff = shellff -> next;
2115 }
2116 molff = molff -> next;
2117 }
2118 i = tmp_field -> nbody[0];
2119 j = 0;
2120 for (k=0; k<l; k++)
2121 {
2122 bodyff = get_active_body (0, 0);
2123 while (bodyff)
2124 {
2125 vdw_na[0] = vdw_na[1] = vdw_mlist[k]+1;
2126 vdw_a[0] = vdw_a[1] = duplicate_int (vdw_na[0], vdw_aids[k]);
2127 vdw_ma[0] = vdw_ma[1] = duplicate_int (vdw_na[0], vdw_mids[k]);
2128 if (body_identicals(bodyff, nbd, vdw_na, vdw_ma, vdw_a)) break;
2129 bodyff = bodyff -> next;
2130 }
2131 if (! bodyff)
2132 {
2133 bodyff = get_active_body (i+j, 0);
2134 bodyff -> next = init_field_nth_body (i+j, 0, vdw_na, vdw_ma, vdw_a);
2135 bodyff -> next -> prev = bodyff;
2136 j ++;
2137 }
2138 }
2139 for (m=0; m<l-1; m++)
2140 {
2141 for (n=m+1; n<l; n++)
2142 {
2143 bodyff = get_active_body (0, 0);
2144 while (bodyff)
2145 {
2146 vdw_na[0] = vdw_mlist[m]+1;
2147 vdw_na[1] = vdw_mlist[n]+1;
2148 vdw_a[0] = duplicate_int (vdw_na[0], vdw_aids[m]);
2149 vdw_a[1] = duplicate_int (vdw_na[1], vdw_aids[n]);
2150 vdw_ma[0] = duplicate_int (vdw_na[0], vdw_mids[m]);
2151 vdw_ma[1] = duplicate_int (vdw_na[1], vdw_mids[n]);
2152 if (body_identicals(bodyff, nbd, vdw_na, vdw_ma, vdw_a)) break;
2153 bodyff = bodyff -> next;
2154 }
2155 if (! bodyff)
2156 {
2157 bodyff = get_active_body (i+j, 0);
2158 bodyff -> next = init_field_nth_body (i+j, 0, vdw_na, vdw_ma, vdw_a);
2159 bodyff -> next -> prev = bodyff;
2160 j ++;
2161 }
2162 }
2163 }
2164 tmp_field -> nbody[0] += j;
2165 }
2166 else
2167 {
2168 atff = get_active_atom (tmp_fmol -> id, tmp_fshell -> ia[0]);
2169 gchar * str = g_strdup_printf ("%s_sh", atff -> name);
2170 gchar * stra, * strb;
2171 bodyff = get_active_body (0, 0);
2172 i = 0;
2173 while (bodyff)
2174 {
2175 stra = get_body_element_name (bodyff, 0, m+1);
2176 strb = get_body_element_name (bodyff, 1, m+1);
2177 if (g_strcmp0(str,stra) == 0 || g_strcmp0(str,strb) == 0)
2178 {
2179 if (bodyff -> next)
2180 {
2181 bodyff -> prev -> next = bodyff -> next;
2182 bodyff -> next -> prev = bodyff -> prev;
2183 }
2184 else
2185 {
2186 bodyff = bodyff -> prev;
2187 g_free (bodyff -> next);
2188 bodyff -> next = NULL;
2189 }
2190 i ++;
2191 }
2192 g_free (stra);
2193 g_free (strb);
2194 bodyff = bodyff -> next;
2195 }
2196 g_free (str);
2197 tmp_field -> nbody[0] -= i;
2198 }
2199}
2200
2201#ifdef GTK4
2210G_MODULE_EXPORT void shell_in_vdw (GtkCheckButton * but, gpointer data)
2211#else
2220G_MODULE_EXPORT void shell_in_vdw (GtkToggleButton * but, gpointer data)
2221#endif
2222{
2223 tmp_fshell -> vdw = button_get_status ((GtkWidget *)but);
2225}
2226
2229
2239G_MODULE_EXPORT void run_edit_parameters (GtkDialog * dialog, gint response_id, gpointer data)
2240{
2241 if (rep.a > 6 && rep.a < MOLIMIT)
2242 {
2244 }
2245 else if (rep.a == 1)
2246 {
2247 if (g_strcmp0 (rep_atom_name, tmp_fat -> name) != 0)
2248 {
2249 // Atom name's change, need to update non bonded interactions
2250 compare_non_bonded (tmp_fat -> name);
2251 }
2252 g_free (rep_atom_name);
2253 rep_atom_name = NULL;
2254 }
2255 destroy_this_dialog (dialog);
2256}
2257
2266void edit_parameters (int f, int id)
2267{
2268 gchar * str = g_strdup_printf ("%s parameter(s)", felemts[f+1]);
2269 GtkWidget * dialog = dialogmodal(str, GTK_WINDOW(field_assistant));
2270 GtkWidget * lab;
2271 GtkWidget * entry;
2272 GtkWidget * but;
2273 GtkWidget * hbox;
2274 GtkWidget * combo;
2275 GtkWidget * box = dialog_get_content_area (dialog);
2276 gboolean show_it;
2277 gboolean use_it;
2278 gchar * cs_name[3]={"Core atom: ", "Shell atom: ", "Selection: "};
2279 gchar * cs_param[4]={"Mass:", "Charge:", "<i>k<sub>2</sub></i> ", "<i>k<sub>4</sub></i> "};
2280 gchar * cs_unit[4]={"g mol<sup>-1</sup>", " ", "&#xC5;<sup>-2</sup>", "&#xC5;<sup>-4</sup>"};
2281 gchar * co_name[4]={"First atom: ", "Second atom: ", "Third atom: ", "Fourth atom: "};
2282 gchar * pm_name[2]={"First unit: ", "Second unit: "};
2283 int i, j, k, l, m;
2284 float v;
2285 gchar * ba;
2286 is_moy = 1;
2287 show_it = use_it = FALSE;
2288 for (i=0; i<2; i++) ff_p_combo[i] = NULL;
2289 if (f < MOLIMIT)
2290 {
2291 i = combo_get_active (combo_mol[f-1]);
2292 lab = markup_label (g_strdup_printf ("\tMolecule: \t<b>%s</b>", get_active_field_molecule(i) -> name), -1, 30, 0.0, 0.5);
2293 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2295 }
2296 switch (f)
2297 {
2298 case 1:
2299 // Atom edit
2300 tmp_fat = get_active_atom(i, id);
2301 rep_atom_name = g_strdup_printf("%s", tmp_fat -> name);
2302 lab = markup_label (g_strdup_printf ("\tAtom: \t\t<b>%s</b>", rep_atom_name), -1, 50, 0.0, 0.5);
2303 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2304 hbox = create_hbox (0);
2305 str = g_strdup_printf ("Element:");
2306 lab = markup_label (str, 120, 30, 0.0, 0.5);
2307 g_free (str);
2308 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2309 str = g_strdup_printf ("%s", exact_name(tmp_proj -> chemistry -> element[tmp_fat -> sp]));
2310 lab = markup_label (str, -1, -1, 0.5, 0.5);
2311 g_free (str);
2312 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 0);
2313 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2314 hbox = create_hbox (0);
2315 str = g_strdup_printf ("Field parameters:");
2316 lab = markup_label (str, 120, -1, 0.0, 0.5);
2317 g_free (str);
2318 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2319 combo = create_combo ();
2320 combo_text_append (combo, "Manual");
2321 combo_text_append (combo, "Automatic");
2322 combo_set_active (combo, (tmp_fat -> afid > -1) ? 1 : 0);
2323 widget_set_sensitive (combo, atoms_id[tmp_fat -> sp]);
2324 g_signal_connect (G_OBJECT(combo), "changed", G_CALLBACK(changed_atom_combo), GINT_TO_POINTER(0));
2325 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, combo, FALSE, FALSE, 0);
2326 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2327 hbox = create_hbox (0);
2328 str = g_strdup_printf ("Force field type <sup>*</sup>:");
2329 lab = markup_label (str, 120, 30, 0.0, 0.5);
2330 g_free (str);
2331 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2332 afftype = create_combo ();
2333 combo_text_append (afftype, "None");
2334 k = 0;
2335 for (i=0; i<atoms_id[tmp_fat -> sp]; i++)
2336 {
2337 j = atoms_id_list[tmp_fat -> sp][i];
2338 str = g_strdup_printf ("%s", exact_name(ff_atoms[j][2]));
2339 if (g_strcmp0 (ff_atoms[j][3], " ") != 0) str = g_strdup_printf ("%s : %s", str, ff_atoms[j][3]);
2341 g_free (str);
2342 if (atoms_id_list[tmp_fat -> sp][i] == tmp_fat -> afid) k = i+1;
2343 }
2345 g_signal_connect (G_OBJECT(afftype), "changed", G_CALLBACK(changed_atom_combo), GINT_TO_POINTER(1));
2346 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, afftype, FALSE, FALSE, 0);
2347 widget_set_sensitive (afftype, (tmp_fat -> afid > -1) ? TRUE : FALSE);
2348 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2349 hbox = create_hbox (0);
2350 str = g_strdup_printf ("Name: ");
2351 lab = markup_label (str, 120, -1, 0.0, 0.5);
2352 g_free (str);
2353 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2354 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(-1));
2355 update_entry_text (GTK_ENTRY(entry), tmp_fat -> name);
2356 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2357 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2358 hbox = create_hbox (0);
2359 str = g_strdup_printf ("Mass: ");
2360 lab = markup_label (str, 120, -1, 0.0, 0.5);
2361 g_free (str);
2362 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2363 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(0));
2364 update_entry_double (GTK_ENTRY(entry), tmp_fat -> mass);
2365 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2366 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2367 hbox = create_hbox (0);
2368 str = g_strdup_printf ("Charge: ");
2369 lab = markup_label (str, 120, -1, 0.0, 0.5);
2370 g_free (str);
2371 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2372 entry = create_entry (G_CALLBACK(update_atom_parameter), 100, 15, FALSE, GINT_TO_POINTER(1));
2373 update_entry_double (GTK_ENTRY(entry), tmp_fat -> charge);
2374 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2375 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2376 hbox = create_hbox (0);
2377 str = g_strdup_printf ("Frozen: ");
2378 lab = markup_label (str, 120, -1, 0.0, 0.5);
2379 g_free (str);
2380 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2381 str = g_strdup_printf ("%d atom(s)", tmp_fat -> frozen);
2382 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(select_atom_id_from_fied_molecule), GINT_TO_POINTER(1));
2383 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2384 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2385 break;
2386 case 2:
2387 // Shell edit
2388 tmp_fshell = get_active_shell (i, id);
2389 str = g_strdup_printf ("\tCore-Shell N°<b>%d</b>", tmp_fshell -> id+1);
2390 lab = markup_label (str, 300, 50, 0.0, 0.5);
2391 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2392 for (k=0; k<2; k++)
2393 {
2394 hbox = create_hbox (0);
2395 lab = markup_label (cs_name[k], 100, -1, 0.0, 0.5);
2396 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2397 if (! tmp_fshell -> ia[k])
2398 {
2399 str = g_strdup_printf ("Not picked yet !");
2401 }
2402 else
2403 {
2404 j = tmp_fshell -> ia[k] - 1;
2405 l = tmp_fmol -> atoms_id[j][0].a;
2406 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, l) -> sp]), tmp_fshell -> ia[k]);
2407 img_but[k] = stock_image (APPLY);
2408 }
2409 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+2));
2410 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2411 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2412 }
2413
2414 /*for (k=0; k<3; k++)
2415 {
2416 shell_hbox[k] = create_hbox (0);
2417 lab = markup_label (cs_name[k], 100, -1, 0.0, 0.5);
2418 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], lab, FALSE, FALSE, 10);
2419 if ((k < 2 && tmp_fshell -> ia[k] == -1) || (k == 2 && ! tmp_fshell -> ib))
2420 {
2421 str = g_strdup_printf ("Not picked yet !");
2422 img_but[k] = stock_image (DELETEB);
2423 }
2424 else
2425 {
2426 if (k < 2)
2427 {
2428 str = g_strdup_printf ("Selected !");
2429 }
2430 else
2431 {
2432 str = g_strdup_printf ("%d atom(s) selected !", tmp_fshell -> ia[1]-1);
2433 }
2434 img_but[k] = stock_image (APPLY);
2435 }
2436 if (k < 2)
2437 {
2438 shell_cbox[k] = create_combo ();
2439 combo_text_append (shell_cbox[k], "Not picked yet !");
2440 switch (k)
2441 {
2442 case 0:
2443 tmp_fat = tmp_fmol -> first_atom;
2444 while (tmp_fat)
2445 {
2446 combo_text_append (shell_cbox[k], tmp_fat -> name);
2447 tmp_fat = tmp_fat -> next;
2448 }
2449 break;
2450 case 1:
2451 combo_text_append (shell_cbox[k], "All atoms");
2452 combo_text_append (shell_cbox[k], "Selected atoms");
2453 break;
2454 }
2455 l = (! k) ? tmp_fshell -> ia[k]+1 : (tmp_fshell -> ia[k] < 1) ? tmp_fshell -> ia[k]+1 : 2;
2456 combo_set_active (shell_cbox[k], l);
2457 g_signal_connect (G_OBJECT(shell_cbox[k]), "changed", G_CALLBACK(changed_shell_combo), GINT_TO_POINTER(k));
2458 gtk_widget_set_size_request (shell_cbox[k], 150, -1);
2459 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], shell_cbox[k], FALSE, FALSE, 0);
2460 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], img_but[k], FALSE, FALSE, 30);
2461 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, shell_hbox[k], FALSE, FALSE, 0);
2462 }
2463 else
2464 {
2465 shell_but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(2));
2466 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], shell_but, FALSE, FALSE, 0);
2467 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, shell_hbox[k], img_but[k], FALSE, FALSE, 30);
2468 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, shell_hbox[k], FALSE, FALSE, 0);
2469 }
2470 g_free (str);
2471 }
2472 */
2473 for (k=0; k<4; k++)
2474 {
2475 hbox = create_hbox (0);
2476 lab = markup_label (cs_param[k], 100, -1, 0.0, 0.5);
2477 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2478 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(2+k));
2479 v = (! k) ? tmp_fshell -> m : (k == 1) ? tmp_fshell -> z : (k == 2) ? tmp_fshell -> k2 : tmp_fshell -> k4;
2480 update_entry_double (GTK_ENTRY(entry), v);
2481 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2482 if (k < 2)
2483 {
2484 str = g_strdup_printf ("%s", cs_unit[k]);
2485 }
2486 else
2487 {
2488 str = g_strdup_printf ("%s %s", fkeysw[activef][0][tmp_field -> energy_unit], cs_unit[k]);
2489 }
2490 lab = markup_label (str, -1, -1, 0.0, 0.5);
2491 g_free (str);
2492 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2493 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2494 }
2495 hbox = create_hbox (0);
2496 lab = markup_label("Use non-bonded: ", 185, 40, 0.0, 0.5);
2497 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2498 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button (NULL, -1, -1, tmp_fshell -> vdw, G_CALLBACK(shell_in_vdw), NULL), FALSE, FALSE, 30);
2499 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2500 show_it = tmp_fshell -> show;
2501 use_it = tmp_fshell -> use;
2502 break;
2503 case 3:
2504 // Constraint edit
2506 str = g_strdup_printf ("\tBond constraint N°<b>%d</b>", tmp_fcons -> id+1);
2507 lab = markup_label (str, 300, 50, 0.0, 0.5);
2508 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2509 for (k=0; k<2; k++)
2510 {
2511 hbox = create_hbox (0);
2512 lab = markup_label (co_name[k], 100, -1, 0.0, 0.5);
2513 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2514 if (! tmp_fcons -> ia[k])
2515 {
2516 str = g_strdup_printf ("Not picked yet !");
2518 }
2519 else
2520 {
2521 j = tmp_fcons -> ia[k]-1;
2522 l = tmp_fmol -> atoms_id[j][0].a;
2523 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, l) -> sp]), tmp_fcons -> ia[k]);
2524 img_but[k] = stock_image (APPLY);
2525 }
2526 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+4));
2527 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2528 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2529 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2530 }
2531 hbox = create_hbox (0);
2532 str = g_strdup_printf ("Av. distance (1): ");
2533 lab = markup_label (str, 100, 50, 0.0, 0.5);
2534 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2535 av_lgt = markup_label ("", 150, 50, 0.5, 0.5);
2537 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, av_lgt, FALSE, FALSE, 0);
2538 str = g_strdup_printf ("[&#xC5;]");
2539 lab = markup_label (str, -1, -1, 0.0, 0.5);
2540 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2541 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2542 hbox = create_hbox (0);
2543 str = g_strdup_printf ("Length: ");
2544 lab = markup_label (str, 100, -1, 0.0, 0.5);
2545 g_free (str);
2546 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2547 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(6));
2548 update_entry_double (GTK_ENTRY(entry), tmp_fcons -> length);
2549 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2550 str = g_strdup_printf ("[&#xC5;]");
2551 lab = markup_label (str, -1, -1, 0.0, 0.5);
2552 g_free (str);
2553 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2554 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2555 show_it = tmp_fcons -> show;
2556 use_it = tmp_fcons -> use;
2557 break;
2558 case 4:
2559 // Pmf edit
2560 tmp_fpmf = get_active_pmf (i, id);
2561 str = g_strdup_printf ("\tMean force potential N°<b>%d</b>", tmp_fpmf -> id+1);
2562 lab = markup_label (str, 300, 50, 0.0, 0.5);
2563 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2564 for (k=0; k<2; k++)
2565 {
2566 hbox = create_hbox (0);
2567 lab = markup_label (pm_name[k], 100, -1, 0.0, 0.5);
2568 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2569 if (tmp_fpmf -> num[k] == 0)
2570 {
2571 str = g_strdup_printf ("Not picked yet !");
2573 }
2574 else
2575 {
2576 str = g_strdup_printf ("%d atom(s)", tmp_fpmf -> num[k]);
2577 img_but[k] = stock_image (APPLY);
2578 }
2579 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(k+6));
2580 g_free (str);
2581 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2582 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2583 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2584 }
2585
2586 hbox = create_hbox (0);
2587 str = g_strdup_printf ("Av. d<sub>1-2</sub> (1): ");
2588 lab = markup_label (str, 100, 50, 0.0, 0.5);
2589 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2590 av_lgt = markup_label ("", 150, 50, 0.5, 0.5);
2592 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, av_lgt, FALSE, FALSE, 0);
2593 str = g_strdup_printf ("[&#xC5;]");
2594 lab = markup_label (str, -1, 50, 0.0, 0.5);
2595 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2596 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2597
2598 hbox = create_hbox (0);
2599 str = g_strdup_printf ("Length: ");
2600 lab = markup_label (str, 100, -1, 0.0, 0.5);
2601 g_free (str);
2602 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2603 entry = create_entry (G_CALLBACK(update_atom_parameter), 150, 15, FALSE, GINT_TO_POINTER(7));
2604 update_entry_double (GTK_ENTRY(entry), tmp_fpmf -> length);
2605 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, entry, FALSE, FALSE, 0);
2606 str = g_strdup_printf ("[&#xC5;]");
2607 lab = markup_label (str, -1, -1, 0.0, 0.5);
2608 g_free (str);
2609 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 30);
2610 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2611 show_it = tmp_fpmf -> show;
2612 use_it = tmp_fpmf -> use;
2613 break;
2614 case 5:
2615 // Rigid edit
2616 tmp_frig = get_active_rigid (i, id);
2617 str = g_strdup_printf ("\tRigid unit N°<b>%d</b>", id+1);
2618 lab = markup_label (str, 300, 50, 0.0, 0.5);
2619 g_free (str);
2620 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2621
2622 hbox = create_hbox (0);
2623 str = g_strdup_printf ("Atom(s): ");
2624 lab = markup_label (str, 100, -1, 0.0, 0.5);
2625 g_free (str);
2626 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2627 if (tmp_frig -> num == 0)
2628 {
2629 str = g_strdup_printf ("Not picked yet !");
2631 }
2632 else
2633 {
2634 str = g_strdup_printf ("%d atom(s)", tmp_frig -> num);
2635 img_but[0] = stock_image (APPLY);
2636 }
2637 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(8));
2638 g_free (str);
2639 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2640 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[0], FALSE, FALSE, 30);
2641 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2642 show_it = tmp_frig -> show;
2643 use_it = tmp_frig -> use;
2644 break;
2645 case 6:
2646 // Tethered
2647 tmp_ftet = get_active_tethered (i, id);
2648 str = g_strdup_printf ("\tTethered atom N°<b>%d</b>", id+1);
2649 lab = markup_label (str, 300, 50, 0.0, 0.5);
2650 g_free (str);
2651 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2652
2653 hbox = create_hbox (0);
2654 str = g_strdup_printf ("Atom: ");
2655 lab = markup_label (str, 100, -1, 0.0, 0.5);
2656 g_free (str);
2657 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2658 if (! tmp_ftet -> num)
2659 {
2660 str = g_strdup_printf ("Not picked yet !");
2662 }
2663 else
2664 {
2665 k = tmp_fmol -> atoms_id[tmp_ftet -> num-1][0].a;
2666 str = g_strdup_printf ("%s - %d", exact_name(tmp_proj -> chemistry -> label[get_active_atom (i, k) -> sp]), tmp_ftet -> num);
2667 img_but[0] = stock_image (APPLY);
2668 }
2669 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(9));
2670 g_free (str);
2671 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2672 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[0], FALSE, FALSE, 30);
2673 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2674 show_it = tmp_ftet -> show;
2675 use_it = tmp_ftet -> use;
2676 break;
2677 case SEXTERN:
2679 body_lab = markup_label (field_str(tmp_fext -> key), 250, 50, 0.5, 0.5);
2680 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, body_lab, FALSE, FALSE, 0);
2681 use_it = tmp_fext -> use;
2682 break;
2683 default:
2684 if (f < MOLIMIT)
2685 {
2686 // Bond, angle, dihedral, improper, inversion edit
2687 tmp_fstr = get_active_struct (f-7, i, id);
2688 m = struct_id (f);
2689 str = g_strdup_printf ("\t%s type N°<b>%d</b>\n\tField atoms: <b>", mo_title[f-7], id+1);
2690 for (k=0; k<m; k++)
2691 {
2692 if (k == m-1) str = g_strdup_printf ("%s</b> and <b>", str);
2693 str = g_strdup_printf ("%s%s", str, get_active_atom (i, tmp_fstr -> aid[k]) -> name);
2694 if (m > 2 && k < m-1) str = g_strdup_printf ("%s</b>, <b>", str);
2695 }
2696 str = g_strdup_printf ("%s</b>", str);
2697 edit_atids = allocint (m);
2698 gtk_tree_model_get (GTK_TREE_MODEL(field_model[f]), & field_iter, 0, & is_moy, -1);
2699 if (! is_moy)
2700 {
2701 str = g_strdup_printf ("%s\n\tBetween atoms: <b>", str);
2702 for (k=0; k<m; k++)
2703 {
2704 gtk_tree_model_get (GTK_TREE_MODEL(field_model[f]), & field_iter, k+1, & ba, -1);
2705 edit_atids[k] = (int) string_to_double ((gpointer)ba) - 1;
2706 if (k == m-1) str = g_strdup_printf ("%s</b> and <b>", str);
2707 str = g_strdup_printf ("%s%s", str, ba);
2708 if (m > 2 && k < m-1) str = g_strdup_printf ("%s</b>, <b>", str);
2709 }
2710 str = g_strdup_printf ("%s</b>", str);
2711 if (tmp_fstr -> other)
2712 {
2714 if (! tmp_fprop)
2715 {
2716 tmp_fprop = tmp_fstr -> other;
2717 while (tmp_fprop -> next) tmp_fprop = tmp_fprop -> next;
2718 tmp_fprop -> next = duplicate_field_prop (tmp_fstr -> def, f-7);
2719 tmp_fprop = tmp_fprop -> next;
2720 for (k=0; k<m; k++) tmp_fprop -> aid[k] = edit_atids[k];
2721 }
2722 }
2723 else
2724 {
2725 tmp_fstr -> other = duplicate_field_prop (tmp_fstr -> def, f-7);
2726 for (k=0; k<m; k++) tmp_fstr -> other -> aid[k] = edit_atids[k];
2727 tmp_fprop = tmp_fstr -> other;
2728 }
2729 }
2730 else
2731 {
2732 for (l=0; l<m; l++) edit_atids[l] = -1;
2733 tmp_fprop = tmp_fstr -> def;
2734 }
2735 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, markup_label (str, -1, (is_moy) ? 70 : 100, 0.0, 0.5), FALSE, FALSE, 0);
2736 g_free (str);
2737 show_it = tmp_fprop -> show;
2738 use_it = tmp_fprop -> use;
2739 }
2740 else
2741 {
2742 l = f - MOLIMIT;
2743 tmp_fbody = get_active_body (id, l);
2744 body_lab = markup_label (body_str (tmp_fbody -> bd), 250, 50, 0.5, 0.5);
2745 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, body_lab, FALSE, FALSE, 0);
2746 if (l > 0)
2747 {
2748 for (k=0; k< body_at(l); k++)
2749 {
2750 hbox = create_hbox (0);
2751 if (l == 2)
2752 {
2753 lab = markup_label ("Tersoff atom: ", 100, -1, 0.0, 0.5);
2754 }
2755 else
2756 {
2757 lab = markup_label (co_name[k], 100, -1, 0.0, 0.5);
2758 }
2759 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2760 if (tmp_fbody -> na[k] < 0)
2761 {
2762 str = g_strdup_printf ("Not picked yet !");
2764 }
2765 else
2766 {
2767 str = g_strdup_printf ("%s", get_active_atom (tmp_fbody -> ma[k][0], tmp_fbody -> a[k][0]) -> name);
2768 img_but[k] = stock_image (APPLY);
2769 }
2770 but = create_button (str, IMG_NONE, NULL, 150, -1, GTK_RELIEF_NORMAL, G_CALLBACK(selection_button), GINT_TO_POINTER(11+k));
2771 g_free (str);
2772 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, but, FALSE, FALSE, 0);
2773 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, img_but[k], FALSE, FALSE, 30);
2774 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2775 }
2776 }
2777 show_it = tmp_fbody -> show;
2778 use_it = tmp_fbody -> use;
2779 }
2780 break;
2781 }
2782 if (f < SEXTERN)
2783 {
2784 hbox = create_hbox (0);
2785 lab = markup_label("Visualize in the model: ", (f == 1) ? 150 : 185, 40, 0.0, 0.5);
2786 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2787 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button (NULL, -1, -1, show_it, G_CALLBACK(visualize_it), GINT_TO_POINTER(f)), FALSE, FALSE, 30);
2788 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2789 }
2790 if (f == 1)
2791 {
2792 str = g_strdup_printf ("<sup>*</sup> this will be used to adjust bonding, angles, etc ... accordingly,\n"
2793 " providing that some parameters can be found in the force field data.\n"
2794 " Please note that comments are directly imported from the force field file.");
2795 lab = markup_label (str, -1, 75, 0.5, 0.5);
2796 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2797 }
2798 if (f > 1)
2799 {
2800 hbox = create_hbox (0);
2801 lab = markup_label("Use to create force field: ", 185, 40, 0.0, 0.5);
2802 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2803 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, check_button (NULL, -1, -1, use_it, G_CALLBACK(select_it), GINT_TO_POINTER(f)), FALSE, FALSE, 30);
2804 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2805 if (f > 5)
2806 {
2807 if (f > 6 && f < 16)
2808 {
2809 if (f != 15 || tmp_field -> type < CFF91 || tmp_field -> type > COMPASS)
2810 {
2811 hbox = create_hbox (0);
2812 gchar * funits[5] ={"Ev", "kcal mol<sup>-1</sup>", "kJ mol<sup>-1</sup>", "K B<sup>-1</sup>", "DL_POLY internal units"};
2813 str = g_strdup_printf ("Field parameters <sup>*</sup>:");
2814 lab = markup_label (str, 120, -1, 0.0, 0.5);
2815 g_free (str);
2816 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2817 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, create_field_prop_combo (f, is_moy), FALSE, FALSE, 0);
2818 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2819 str = g_strdup_printf ("<sup>*</sup> Available parameters with matching chemical species,\n"
2820 " %s force field energy related parameters in: %s \n"
2821 " if required conversion to FIELD file energy unit will be performed upon selection.\n"
2822 " Please note that comments are directly imported from the force field file.\n",
2823 field_acro[tmp_field -> type], funits[ff_unit]);
2824 lab = markup_label (str, -1, 75, 0.5, 0.5);
2825 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, lab, FALSE, FALSE, 0);
2826 }
2827 }
2828 hbox = create_hbox (0);
2829 str = g_strdup_printf ("Potential: ");
2830 lab = markup_label (str, 100, -1, 0.0, 0.5);
2831 g_free (str);
2832 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2834 for (j=0; j<fetypes[activef][f-5]; j++)
2835 {
2836 str = g_strdup_printf ("%s (%s)", fnames[activef][f-5][j], exact_name(fkeysw[activef][f-5][j]));
2838 g_free (str);
2839 }
2840 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, field_key_combo, FALSE, FALSE, 0);
2841 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2842 param_box = create_hbox (0);
2844 switch (f)
2845 {
2846 case 6:
2847 // Tethered
2849 break;
2850 case SEXTERN:
2852 break;
2853 default:
2854 if (f < MOLIMIT)
2855 {
2857 }
2858 else
2859 {
2860 // non nonded
2862 }
2863 break;
2864 }
2865 g_signal_connect (G_OBJECT(field_key_combo), "changed", G_CALLBACK(changed_field_key_combo), GINT_TO_POINTER(f));
2866 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, param_box, p_box, FALSE, FALSE, 0);
2867 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, param_box, FALSE, FALSE, 5);
2868 }
2869 else if (f == 3)
2870 {
2871 hbox = create_hbox (0);
2872 str = g_strdup_printf (" <b>(1)</b> average distance between the 2 atoms\n"
2873 "\tas measured in the 3D model");
2874 lab = markup_label (str, 320, -1, 0.0, 0.5);
2875 g_free (str);
2876 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2877 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2878 }
2879 else if (f == 4)
2880 {
2881 hbox = create_hbox (0);
2882 str = g_strdup_printf (" <b>(1)</b> average distance between the barycenters\n"
2883 "\tof units 1 and 2 as measured in the model");
2884 lab = markup_label (str, 320, -1, 0.0, 0.5);
2885 g_free (str);
2886 add_box_child_start (GTK_ORIENTATION_HORIZONTAL, hbox, lab, FALSE, FALSE, 10);
2887 add_box_child_start (GTK_ORIENTATION_VERTICAL, box, hbox, FALSE, FALSE, 0);
2888 }
2889 }
2890 rep.a = f;
2891 rep.b = m;
2892 g_signal_connect (G_OBJECT(dialog), "response", G_CALLBACK(run_edit_parameters), NULL);
2893 show_the_widgets (dialog);
2894 if (f == 2)
2895 {
2896 if (tmp_fshell -> ia[0] < 0 || tmp_fshell -> ia[1] < 1) hide_the_widgets (shell_hbox[2]);
2897 if (tmp_fshell -> ia[0] < 0) widget_set_sensitive (shell_hbox[1], FALSE);
2898 }
2899
2900 dialog_id ++;
2901 Event_loop[dialog_id] = g_main_loop_new (NULL, FALSE);
2902 g_main_loop_run (Event_loop[dialog_id]);
2903}
2904
2913void update_tersoffs (int id, int key)
2914{
2915 int i;
2916 field_nth_body * bod = tmp_field -> first_body[2];
2917 for (i=0; i<tmp_field -> nbody[2]; i++)
2918 {
2919 if (i != id)
2920 {
2921 if (bod -> key != key)
2922 {
2923 bod -> key = key;
2924 bod -> val = NULL;
2925 bod -> val = allocfloat (fvalues[activef][MOLIMIT-4][bod -> key]);
2926 }
2927 }
2928 if (bod -> next != NULL) bod = bod -> next;
2929 }
2930 if (key && tmp_field -> cross != NULL)
2931 {
2932 g_free (tmp_field -> cross);
2933 tmp_field -> cross = NULL;
2934 }
2935}
2936
2945void check_tersoffs (int id, int key)
2946{
2947 int i, j;
2948 if (change_tersoff && id != -1) update_tersoffs (id, key);
2949 if (! key)
2950 {
2951 if (tmp_field -> cross)
2952 {
2953 g_free (tmp_field -> cross);
2954 tmp_field -> cross = NULL;
2955 }
2956 if (cross)
2957 {
2958 tmp_field -> cross = g_malloc (tmp_field -> nbody[2]*sizeof*tmp_field -> cross);
2959 for (i=0; i<tmp_field -> nbody[2]; i++)
2960 {
2961 tmp_field -> cross[i] = g_malloc (tmp_field -> nbody[2]*sizeof*tmp_field -> cross[i]);
2962 for (j=0; j<tmp_field -> nbody[2]; j++) tmp_field -> cross[i][j] = duplicate_double (3, cross[i][j]);
2963 }
2964 }
2965 else
2966 {
2967 tmp_field -> cross = alloctdouble (tmp_field -> nbody[2], tmp_field -> nbody[2], 3);
2968 }
2969 }
2970}
2971
2981G_MODULE_EXPORT void edit_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
2982{
2983 int i, j, k;
2984 i = GPOINTER_TO_INT (data);
2985 gchar * tmp;
2986 switch (i)
2987 {
2988 case 0:
2989 if (action == NULL)
2990 {
2992 tmp = g_strdup_printf ("Please enter name for new molecule N°%d", tmp_field -> molecules);
2993 tmp_fmol -> name = g_strdup_printf("MOL-%d", i);
2994 tmp = cask (tmp, "Molecule name:", 0, tmp_fmol -> name, field_assistant);
2995 if (tmp != NULL)
2996 {
2997 tmp_fmol -> name = g_strdup_printf ("%s", tmp);
2998 g_free (tmp);
2999 }
3000 }
3001 else
3002 {
3004 tmp = g_strdup_printf ("Please enter name for molecule N°%d", row_id+1);
3005 tmp = cask (tmp, "Molecule name:", 0, tmp_fmol -> name, field_assistant);
3006 if (tmp != NULL)
3007 {
3008 tmp_fmol -> name = g_strdup_printf ("%s", tmp);
3009 g_free (tmp);
3011 }
3012 }
3013 break;
3014 default:
3015 if (i == MOLIMIT+2)
3016 {
3017 num_body_d = tmp_field -> nbody[2];
3018 cross = NULL;
3019 if (tmp_field -> cross != NULL)
3020 {
3021 cross = g_malloc (tmp_field -> nbody[2]*sizeof*cross);
3022 for (j=0; j<tmp_field -> nbody[2]; j++)
3023 {
3024 cross[j] = g_malloc (tmp_field -> nbody[2]*sizeof*cross[j]);
3025 for (k=0; k<tmp_field -> nbody[2]; k++) cross[j][k] = duplicate_double (3, tmp_field -> cross[j][k]);
3026 }
3027 }
3028 change_tersoff = FALSE;
3029 }
3031 if (i == MOLIMIT+2) check_tersoffs (tmp_fbody -> id, tmp_fbody -> key);
3033 break;
3034 }
3035}
3036
3046G_MODULE_EXPORT void add_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
3047{
3048 int i, j, k, l, m;
3049 gboolean save_it;
3050 i = GPOINTER_TO_INT (data);
3051 field_molecule * fmol;
3052 if (i < MOLIMIT)
3053 {
3054 j = combo_get_active (combo_mol[i-1]);
3056 }
3057 if (i == 2)
3058 {
3059 if (fmol -> first_shell == NULL)
3060 {
3061 fmol -> first_shell = init_field_shell (fmol -> shells, 0, 0);
3062 }
3063 else
3064 {
3065 tmp_fshell = get_active_shell (j, fmol -> shells);
3066 tmp_fshell -> next = init_field_shell (fmol -> shells, 0, 0);
3067 tmp_fshell -> next -> prev = g_malloc (sizeof*tmp_fshell -> next -> prev);
3068 tmp_fshell -> next -> prev = tmp_fshell;
3069 }
3070 row_id = fmol -> shells;
3071 edit_parameters (i, fmol -> shells);
3072 if (tmp_fshell -> ia[0] || tmp_fshell -> ia[1])
3073 {
3074 fmol -> shells ++;
3075 if (! tmp_fshell -> ia[0] || ! tmp_fshell -> ia[1]) tmp_fshell -> use = FALSE;
3076 }
3077 else
3078 {
3079 tmp_fshell = get_active_shell (j, fmol -> shells);
3080 tmp_fshell -> next = NULL;
3081 if (fmol -> shells == 0) fmol -> first_shell = NULL;
3082 }
3083 }
3084 else if (i == 3)
3085 {
3086 if (fmol -> first_constraint == NULL)
3087 {
3088 fmol -> first_constraint = init_field_constraint (fmol -> constraints, 0, 0);
3089 }
3090 else
3091 {
3092 tmp_fcons = get_active_constraint (j, fmol -> constraints);
3093 tmp_fcons -> next = init_field_constraint (fmol -> constraints, 0, 0);
3094 tmp_fcons -> next -> prev = g_malloc0 (sizeof*tmp_fcons -> next -> prev);
3095 tmp_fcons -> next -> prev = tmp_fcons;
3096 }
3097 row_id = fmol -> constraints;
3098 edit_parameters (i, fmol -> constraints);
3099 if (tmp_fcons -> ia[0] || tmp_fcons -> ia[1])
3100 {
3101 fmol -> constraints ++;
3102 if (! tmp_fcons -> ia[0] || ! tmp_fcons -> ia[1]) tmp_fcons -> use = FALSE;
3103 }
3104 else
3105 {
3106 tmp_fcons = get_active_constraint (j, fmol -> constraints);
3107 tmp_fcons -> next = NULL;
3108 if (fmol -> constraints == 0) fmol -> first_constraint = NULL;
3109 }
3110 }
3111 else if (i == 4)
3112 {
3113 if (fmol -> first_pmf == NULL)
3114 {
3115 fmol -> first_pmf = init_field_pmf (fmol -> pmfs, NULL, NULL, NULL);
3116 }
3117 else
3118 {
3119 tmp_fpmf = get_active_pmf (j, fmol -> pmfs);
3120 tmp_fpmf -> next = init_field_pmf (fmol -> pmfs, NULL, NULL, NULL);
3121 tmp_fpmf -> next -> prev = g_malloc0 (sizeof*tmp_fpmf -> next -> prev);
3122 tmp_fpmf -> next -> prev = tmp_fpmf;
3123 }
3124 row_id = fmol -> pmfs;
3125 edit_parameters (i, fmol -> pmfs);
3126 if (tmp_fpmf -> num[0] > 0 || tmp_fpmf -> num[1] > 0)
3127 {
3128 fmol -> pmfs ++;
3129 if (tmp_fpmf -> length == 0.0 || tmp_fpmf -> num[0] == 0 || tmp_fpmf -> num[1] == 0) tmp_fpmf -> use = FALSE;
3130 if (tmp_fpmf -> use)
3131 {
3132 toviz.c = TRUE;
3133 select_object (i, fmol -> pmfs, j);
3134 }
3135 }
3136 else
3137 {
3138 tmp_fpmf = get_active_pmf (j, fmol -> pmfs);
3139 tmp_fpmf -> next = NULL;
3140 if (fmol -> pmfs == 0) fmol -> first_pmf = NULL;
3141 }
3142 }
3143 else if (i == 5)
3144 {
3145 if (fmol -> first_rigid == NULL)
3146 {
3147 fmol -> first_rigid = init_field_rigid (fmol -> rigids, 0, NULL);
3148 }
3149 else
3150 {
3151 tmp_frig = get_active_rigid (j, fmol -> rigids);
3152 tmp_frig -> next = init_field_rigid (fmol -> rigids, 0, NULL);
3153 tmp_frig -> next -> prev = g_malloc0 (sizeof*tmp_frig -> next -> prev);
3154 tmp_frig -> next -> prev = tmp_frig;
3155 }
3156 row_id = fmol -> rigids;
3157 edit_parameters (i, fmol -> rigids);
3158 if (tmp_frig -> num > 0)
3159 {
3160 fmol -> rigids ++;
3161 tmp_frig -> use = TRUE;
3162 }
3163 else
3164 {
3165 tmp_frig = get_active_rigid (j, fmol -> rigids);
3166 tmp_frig -> next = NULL;
3167 if (fmol -> rigids == 0) fmol -> first_rigid = NULL;
3168 }
3169 }
3170 else if (i == 6)
3171 {
3172 if (fmol -> first_tethered == NULL)
3173 {
3174 fmol -> first_tethered = init_field_tethered (fmol -> tethered, 0);
3175 }
3176 else
3177 {
3178 tmp_ftet = get_active_tethered (j, fmol -> tethered);
3179 tmp_ftet -> next = init_field_tethered (fmol -> tethered, 0);
3180 tmp_ftet -> next -> prev = g_malloc0 (sizeof*tmp_ftet -> next -> prev);
3181 tmp_ftet -> next -> prev = tmp_ftet;
3182 }
3183 row_id = fmol -> tethered;
3184 edit_parameters (i, fmol -> tethered);
3185 if (tmp_ftet -> num)
3186 {
3187 fmol -> tethered ++;
3188 tmp_ftet -> use = TRUE;
3189 }
3190 else
3191 {
3192 tmp_ftet = get_active_tethered (j, fmol -> tethered);
3193 tmp_ftet -> next = NULL;
3194 if (fmol -> tethered == 0) fmol -> first_tethered = NULL;
3195 }
3196 }
3197 else if (i == SEXTERN)
3198 {
3199 if (tmp_field -> first_external == NULL)
3200 {
3201 tmp_field -> first_external = init_field_external (tmp_field -> extern_fields);
3202 }
3203 else
3204 {
3205 tmp_fext = get_active_external (tmp_field -> extern_fields-1);
3206 tmp_fext -> next = init_field_external (tmp_field -> extern_fields);
3207 tmp_fext -> next -> prev = g_malloc0 (sizeof*tmp_fext -> next -> prev);
3208 tmp_fext -> next -> prev = tmp_fext;
3209 }
3210 row_id = tmp_field -> extern_fields;
3211 edit_parameters (i, tmp_field -> extern_fields);
3212 if (tmp_fext -> use && tmp_fext -> key > -1)
3213 {
3214 tmp_field -> extern_fields ++;
3215 }
3216 else
3217 {
3218 tmp_fext = get_active_external (tmp_field -> extern_fields);
3219 tmp_fext -> next = NULL;
3220 if (tmp_field -> extern_fields == 0) tmp_field -> first_external = NULL;
3221 }
3222 }
3223 else
3224 {
3225 j = i - MOLIMIT;
3226 row_id = tmp_field -> nbody[j];
3227 if (tmp_field -> first_body[j] == NULL)
3228 {
3229 tmp_field -> first_body[j] = init_field_nth_body (tmp_field -> nbody[j], j, NULL, NULL, NULL);
3230 }
3231 else
3232 {
3233 tmp_fbody = get_active_body (tmp_field -> nbody[j], j);
3234 tmp_fbody -> next = init_field_nth_body (tmp_field -> nbody[j], j, NULL, NULL, NULL);
3235 tmp_fbody -> next -> prev = g_malloc0 (sizeof*tmp_fbody -> next -> prev);
3236 tmp_fbody -> next -> prev = tmp_fbody;
3237 }
3238 if (j == 2)
3239 {
3240 cross = NULL;
3241 cross = alloctdouble (tmp_field -> nbody[j]+1, tmp_field -> nbody[j]+1, 3);
3242 if (tmp_field -> cross != NULL)
3243 {
3244 for (k=0; k<tmp_field -> nbody[j]; k++)
3245 {
3246 for (l=0; l<tmp_field -> nbody[j]; l++)
3247 {
3248 for (m=0; m<3; m++) cross[k][l][m] = cross[l][k][m] = tmp_field -> cross[k][l][m];
3249 }
3250 }
3251 }
3252 else
3253 {
3254 tmp_field -> cross = alloctdouble (1, 1, 3);
3255 }
3256 }
3257 edit_parameters (i, tmp_field -> nbody[j]);
3258 save_it = FALSE;
3259 k = body_at (j);
3260 for (l=0; l<k; l++) if (tmp_fbody -> na[l] > -1) save_it = TRUE;
3261 if (save_it)
3262 {
3263 tmp_field -> nbody[j] ++;
3264 for (l=0; l<k; l++) if (tmp_fbody -> na[l] < 0) tmp_fbody -> use = FALSE;
3265 if (j == 2) check_tersoffs (tmp_fbody -> id, tmp_fbody -> key);
3266 }
3267 else
3268 {
3269 tmp_fbody = get_active_body (tmp_field -> nbody[j], j);
3270 tmp_fbody -> next = NULL;
3271 if (tmp_field -> nbody[j] == 0) tmp_field -> first_body[j] = NULL;
3272 }
3273 }
3275}
3276
3286G_MODULE_EXPORT void remove_field_prop (GSimpleAction * action, GVariant * parameter, gpointer data)
3287{
3288 int i, j, k, l, m, n, o;
3289 i = GPOINTER_TO_INT (data);
3290 gchar * str;
3291 if (i < MOLIMIT)
3292 {
3293 j = combo_get_active (combo_mol[i-1]);
3295 str = g_strdup_printf ("Delete %s N°%d from molecule %s, is this correct ?", elemts[i], row_id+1, tmp_fmol -> name);
3296 }
3297 else
3298 {
3299 str = g_strdup_printf ("Delete %s, is this correct ?", elemts[i]);
3300 }
3301 selection_confirmed = FALSE;
3302 field_question (str, G_CALLBACK(confirm_selection), NULL);
3303 g_free (str);
3305 {
3306 if (i == 2)
3307 {
3309 if (tmp_fshell == tmp_fmol -> first_shell)
3310 {
3311 if (tmp_fshell -> next != NULL)
3312 {
3313 tmp_fmol -> first_shell = tmp_fmol -> first_shell -> next;
3314 tmp_fmol -> first_shell -> prev = NULL;
3315 }
3316 else
3317 {
3318 tmp_fmol -> first_shell = NULL;
3319 }
3320 }
3321 else if (tmp_fshell -> next == NULL)
3322 {
3323 tmp_fshell = tmp_fshell -> prev;
3324 tmp_fshell -> next = NULL;
3325 }
3326 else
3327 {
3328 tmp_fshell -> prev -> next = tmp_fshell -> next;
3329 tmp_fshell -> next -> prev = tmp_fshell -> prev;
3330 }
3331 tmp_fmol -> shells --;
3332 tmp_fshell = tmp_fmol -> first_shell;
3333 for (j=0; j<tmp_fmol -> shells; j++)
3334 {
3335 tmp_fshell -> id = j;
3336 if (tmp_fshell -> next != NULL) tmp_fshell = tmp_fshell -> next;
3337 }
3338 }
3339 else if (i == 3)
3340 {
3342 if (tmp_fcons == tmp_fmol -> first_constraint)
3343 {
3344 if (tmp_fcons -> next != NULL)
3345 {
3346 tmp_fmol -> first_constraint = tmp_fmol -> first_constraint -> next;
3347 tmp_fmol -> first_constraint -> prev = NULL;
3348 }
3349 else
3350 {
3351 tmp_fmol -> first_constraint = NULL;
3352 }
3353 }
3354 else if (tmp_fcons -> next == NULL)
3355 {
3356 tmp_fcons = tmp_fcons -> prev;
3357 tmp_fcons -> next = NULL;
3358 }
3359 else
3360 {
3361 tmp_fcons -> prev -> next = tmp_fcons -> next;
3362 tmp_fcons -> next -> prev = tmp_fcons -> prev;
3363 }
3364 tmp_fmol -> constraints --;
3365 tmp_fcons = tmp_fmol -> first_constraint;
3366 for (j=0; j<tmp_fmol -> constraints; j++)
3367 {
3368 tmp_fcons -> id = j;
3369 if (tmp_fcons -> next != NULL) tmp_fcons = tmp_fcons -> next;
3370 }
3371 }
3372 else if (i == 4)
3373 {
3375 if (tmp_fpmf == tmp_fmol -> first_pmf)
3376 {
3377 if (tmp_fpmf -> next != NULL)
3378 {
3379 tmp_fmol -> first_pmf = tmp_fmol -> first_pmf -> next;
3380 tmp_fmol -> first_pmf -> prev = NULL;
3381 }
3382 else
3383 {
3384 tmp_fmol -> first_pmf = NULL;
3385 }
3386 }
3387 else if (tmp_fpmf -> next == NULL)
3388 {
3389 tmp_fpmf = tmp_fpmf -> prev;
3390 tmp_fpmf -> next = NULL;
3391 }
3392 else
3393 {
3394 tmp_fpmf -> prev -> next = tmp_fpmf -> next;
3395 tmp_fpmf -> next -> prev = tmp_fpmf -> prev;
3396 }
3397 tmp_fmol -> pmfs --;
3398 tmp_fpmf = tmp_fmol -> first_pmf;
3399 for (j=0; j<tmp_fmol -> pmfs; j++)
3400 {
3401 tmp_fpmf -> id = j;
3402 if (tmp_fpmf -> next != NULL) tmp_fpmf = tmp_fpmf -> next;
3403 }
3404 }
3405 else if (i == 5)
3406 {
3408 if (tmp_frig == tmp_fmol -> first_rigid)
3409 {
3410 if (tmp_frig -> next != NULL)
3411 {
3412 tmp_fmol -> first_rigid = tmp_fmol -> first_rigid -> next;
3413 tmp_fmol -> first_rigid -> prev = NULL;
3414 }
3415 else
3416 {
3417 tmp_fmol -> first_rigid = NULL;
3418 }
3419 }
3420 else if (tmp_frig -> next == NULL)
3421 {
3422 tmp_frig = tmp_frig -> prev;
3423 tmp_frig -> next = NULL;
3424 }
3425 else
3426 {
3427 tmp_frig -> prev -> next = tmp_frig -> next;
3428 tmp_frig -> next -> prev = tmp_frig -> prev;
3429 }
3430 tmp_fmol -> rigids --;
3431 tmp_frig = tmp_fmol -> first_rigid;
3432 for (j=0; j<tmp_fmol -> rigids; j++)
3433 {
3434 tmp_frig -> id = j;
3435 if (tmp_frig -> next != NULL) tmp_frig = tmp_frig -> next;
3436 }
3437 }
3438 else if (i == 6)
3439 {
3441 if (tmp_ftet == tmp_fmol -> first_tethered)
3442 {
3443 if (tmp_ftet -> next != NULL)
3444 {
3445 tmp_fmol -> first_tethered = tmp_fmol -> first_tethered -> next;
3446 tmp_fmol -> first_tethered -> prev = NULL;
3447 }
3448 else
3449 {
3450 tmp_fmol -> first_tethered = NULL;
3451 }
3452 }
3453 else if (tmp_ftet -> next == NULL)
3454 {
3455 tmp_ftet = tmp_ftet -> prev;
3456 tmp_ftet -> next = NULL;
3457 }
3458 else
3459 {
3460 tmp_ftet -> prev -> next = tmp_ftet -> next;
3461 tmp_ftet -> next -> prev = tmp_ftet -> prev;
3462 }
3463 tmp_fmol -> tethered --;
3464 tmp_ftet = tmp_fmol -> first_tethered;
3465 for (j=0; j<tmp_fmol -> tethered; j++)
3466 {
3467 tmp_ftet -> id = j;
3468 if (tmp_ftet -> next != NULL) tmp_ftet = tmp_ftet -> next;
3469 }
3470 }
3471 else if (i == SEXTERN)
3472 {
3474 if (tmp_fext == tmp_field -> first_external)
3475 {
3476 if (tmp_fext -> next != NULL)
3477 {
3478 tmp_field -> first_external = tmp_field -> first_external -> next;
3479 tmp_field -> first_external -> prev = NULL;
3480 }
3481 else
3482 {
3483 tmp_field -> first_external = NULL;
3484 }
3485 }
3486 else if (tmp_fext -> next == NULL)
3487 {
3488 tmp_fext = tmp_fext -> prev;
3489 tmp_fext -> next = NULL;
3490 }
3491 else
3492 {
3493 tmp_fext -> prev -> next = tmp_fext -> next;
3494 tmp_fext -> next -> prev = tmp_fext -> prev;
3495 }
3496 tmp_field -> extern_fields --;
3497 tmp_fext = tmp_field -> first_external;
3498 for (k=0; k<tmp_field -> extern_fields; k++)
3499 {
3500 tmp_fext -> id = k;
3501 if (tmp_fext -> next != NULL) tmp_fext = tmp_fext -> next;
3502 }
3503 }
3504 else
3505 {
3506 j = i - MOLIMIT;
3508 if (j == 2)
3509 {
3510 cross = NULL;
3511 if (tmp_field -> nbody[j] > 1)
3512 {
3513 cross = alloctdouble (tmp_field -> nbody[j]-1, tmp_field -> nbody[j]-1, 3);
3514 m = -1;
3515 for (k=0; k<tmp_field -> nbody[j]; k++)
3516 {
3517 if (k != tmp_fbody -> id)
3518 {
3519 m ++;
3520 n = -1;
3521 for (l=0; l<tmp_field -> nbody[j]; l++)
3522 {
3523 if (l != tmp_fbody -> id)
3524 {
3525 n ++;
3526 for (o=0; o<3; o++) cross[m][n][o] = cross[n][m][o] = tmp_field -> cross[k][l][o];
3527 }
3528 }
3529 }
3530 }
3531 }
3532 }
3533 if (tmp_fbody == tmp_field -> first_body[j])
3534 {
3535 if (tmp_fbody -> next != NULL)
3536 {
3537 tmp_field -> first_body[j] = tmp_field -> first_body[j] -> next;
3538 tmp_field -> first_body[j] -> prev = NULL;
3539 }
3540 else
3541 {
3542 tmp_field -> first_body[j] = NULL;
3543 }
3544 }
3545 else if (tmp_fbody -> next == NULL)
3546 {
3547 tmp_fbody = tmp_fbody -> prev;
3548 tmp_fbody -> next = NULL;
3549 }
3550 else
3551 {
3552 tmp_fbody -> prev -> next = tmp_fbody -> next;
3553 tmp_fbody -> next -> prev = tmp_fbody -> prev;
3554 }
3555 tmp_field -> nbody[j] --;
3556 g_free (tmp_fbody);
3557 tmp_fbody = tmp_field -> first_body[j];
3558 k = 0;
3559 while (tmp_fbody)
3560 {
3561 tmp_fbody -> id = k;
3562 k ++;
3563 tmp_fbody = tmp_fbody -> next;
3564 }
3565
3566 if (j == 2) check_tersoffs (-1, tmp_field -> first_body[j] -> key);
3567 }
3569 }
3570}
insertion_menu mol[]
Definition w_library.c:193
void field_question(gchar *question, GCallback handler, gpointer data)
ask the use to confirm something
Definition calc.c:103
gboolean selection_confirmed
Definition calc.c:77
G_MODULE_EXPORT void confirm_selection(GtkDialog *dialog, gint response_id, gpointer data)
confirm that the selection is good
Definition calc.c:88
Variable declarations for the MD input preparation assistants.
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
GtkTreeStore * add_model
Definition cpmd_nose.c:157
void label(cairo_t *cr, double val, int axe, int p, project *this_proj)
draw axis label
Definition labels.c:56
ColRGBA col
Definition d_measures.c:77
int atoms[NUM_STYLES][2]
GtkTreePath * path
Definition datab.c:103
gchar * text
Definition datab.c:105
field_constraint * get_active_constraint(int a, int b)
retrieve constraint property
Definition dlp_active.c:185
field_molecule * get_active_field_molecule(int a)
retrieve field molecule
Definition dlp_active.c:87
field_rigid * get_active_rigid(int a, int b)
retrieve rigid property
Definition dlp_active.c:225
field_prop * get_active_prop_using_atoms(struct field_prop *pr, int ti, int *ids)
retrieve field molecule structural property using atoms
Definition dlp_active.c:286
field_struct * get_active_struct(int s, int a, int b)
retrieve field structural property
Definition dlp_active.c:318
field_shell * get_active_shell(int a, int b)
retrieve shell property
Definition dlp_active.c:165
field_atom * get_active_atom(int a, int b)
retrieve field atom
Definition dlp_active.c:145
field_external * get_active_external(int a)
retrieve external field property
Definition dlp_active.c:125
field_nth_body * get_active_body(int a, int b)
retrieve field nth body interaction
Definition dlp_active.c:106
field_pmf * get_active_pmf(int a, int b)
retrieve PMF property
Definition dlp_active.c:205
field_tethered * get_active_tethered(int a, int b)
retrieve tethered property
Definition dlp_active.c:245
GtkTreeViewColumn * ato_col[4]
Definition dlp_atom.c:62
float val
Definition dlp_init.c:117
GtkCellRenderer * ato_cell[4]
Definition dlp_atom.c:63
field_prop * duplicate_field_prop(field_prop *old_prop, int ti)
create a copy of a field property
Definition dlp_copy.c:218
GtkWidget * combo_cross(field_nth_body *body)
create field cross configuration widgets
Definition dlp_edit.c:467
void select_object(int id, int jd, int kd)
select structural element
Definition dlp_viz.c:423
gchar * mo_title[8]
Definition dlp_field.c:935
int object_is
Definition dlp_edit.c:379
void field_unselect_all()
unselect all atoms
Definition dlp_viz.c:130
dint rep
Definition dlp_edit.c:2227
int * edit_atids
Definition dlp_edit.c:123
float * val_at
Definition dlp_edit.c:1132
void run_select_atom_dialog(GtkDialog *select_dialog, gint response_id, gpointer data)
DL-POLY force field atom selection - creating the dialog.
Definition dlp_atom.c:381
gboolean change_tersoff
Definition dlp_edit.c:420
GtkWidget * shell_but
Definition dlp_edit.c:116
GtkWidget * parameters_box(int obj, int key, gchar **words, float *data)
pepare field property edition parameters
Definition dlp_edit.c:524
G_MODULE_EXPORT void edit_unit_weight(GtkCellRendererText *cell, gchar *path_string, gchar *new_text, gpointer data)
Definition dlp_edit.c:1144
gchar * body_str(int a)
get body potential string name
Definition dlp_edit.c:1630
GtkWidget * add_tree
Definition dlp_edit.c:910
void visualize_single_struct(int id, int jd, int kd, int *ids)
visualize single structural element
Definition dlp_viz.c:486
GtkWidget * shell_hbox[3]
Definition dlp_edit.c:118
void update_field_dist(float v)
update field distance widget
Definition dlp_edit.c:1608
G_MODULE_EXPORT void add_field_prop(GSimpleAction *action, GVariant *parameter, gpointer data)
add field property callback
Definition dlp_edit.c:3046
G_MODULE_EXPORT void update_field_parameter(GtkEntry *res, gpointer data)
update field parameter entry callback
Definition dlp_edit.c:389
int fetypes[2][16]
Definition dlp_field.c:286
void update_tersoffs(int id, int key)
update non bonded potential
Definition dlp_edit.c:2913
int is_moy
Definition dlp_edit.c:122
gchar * felemts[MAXDATA+1]
Definition dlp_field.c:140
gboolean are_identical_prop(int ti, int ai, field_prop *pro_a, field_prop *pro_b)
are the 2 field property identicals ?
Definition dlp_edit.c:135
void select_atom_set_color(GtkCellRenderer *renderer, int i)
set cell renderer color
Definition dlp_edit.c:1022
GtkWidget * img_but[4]
Definition dlp_edit.c:115
void check_tersoffs(int id, int key)
check non bonded potential
Definition dlp_edit.c:2945
G_MODULE_EXPORT void run_add_atom_dialog(GtkDialog *add_dialog, gint response_id, gpointer data)
DL-POLY force field atom selection - running the dialog.
Definition dlp_atom.c:295
G_MODULE_EXPORT void changed_atom_combo(GtkComboBox *box, gpointer data)
change atom
Definition dlp_edit.c:1875
G_MODULE_EXPORT void update_atom_parameter(GtkEntry *res, gpointer data)
update field atom parameter entry callback
Definition dlp_edit.c:337
int ** atoms_id_list
void select_atom_set_cmv(GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *mod, GtkTreeIter *iter, gpointer data)
field atom set renderer color, markup and visibility in the property edition atom(s) selection tree s...
Definition dlp_edit.c:1038
GtkWidget * centry[3]
Definition dlp_edit.c:416
gchar * elemts[MAXDATA]
Definition dlp_field.c:163
GtkWidget * shell_cbox[2]
Definition dlp_edit.c:119
gchar * get_this_vdw_string()
get VdW formalism description string
Definition dlp_edit.c:490
ColRGBA init_color(int id, int numid)
initialize color based id number over total number of elements
Definition initcoord.c:81
gboolean tersoff_question()
change Tersoff potential ?
Definition dlp_edit.c:663
int get_num_vdw_max()
Get the number of field shell interactions.
Definition dlp_edit.c:1994
void compare_non_bonded(gchar *fatom)
compare non bond interaction parameters
Definition dlp_comp.c:184
void adjust_field_prop(int fil, int sti, field_prop *tmp, int *ids, int key)
adjust field property
Definition dlp_edit.c:163
G_MODULE_EXPORT void select_atom_id_from_fied_molecule(GtkButton *but, gpointer data)
select atom id from field molecule - creating the dialog
Definition dlp_edit.c:1163
int ** sel_at
Definition dlp_atom.c:56
GtkWidget * afftype
Definition dlp_edit.c:121
G_MODULE_EXPORT void edit_field_prop(GSimpleAction *action, GVariant *parameter, gpointer data)
edit field property callback
Definition dlp_edit.c:2981
void check_to_visualize_properties_for_this_field_mol(int pid, int mol)
check if rendering is required for object in molecule
Definition dlp_viz.c:735
GtkWidget * create_field_prop_combo(int f, int is_moy)
create field parameter selection combo box
void adjust_vdw_interactions(gboolean add_shell)
adjust VdW interactions
Definition dlp_edit.c:2022
G_MODULE_EXPORT void select_it(GtkToggleButton *but, gpointer data)
select object toggle callback GTK3
Definition dlp_edit.c:888
GtkWidget * param_prop_param_box(int pid)
prepare field parameter edition widgets
Definition dlp_edit.c:687
void field_selection(int i, int viz, int lab, int aid)
select / unselect atom
Definition dlp_viz.c:91
GtkWidget * field_key_combo
Definition dlp_edit.c:111
GtkWidget * body_lab
Definition dlp_edit.c:120
G_MODULE_EXPORT void selection_button(GtkButton *but, gpointer data)
select field object callback
Definition dlp_edit.c:1655
GtkWidget * param_box
Definition dlp_edit.c:114
int a_ato
Definition dlp_atom.c:57
G_MODULE_EXPORT void remove_field_prop(GSimpleAction *action, GVariant *parameter, gpointer data)
remove field property callback
Definition dlp_edit.c:3286
gchar * rep_atom_name
Definition dlp_edit.c:2228
int * atoms_id
GtkWidget * cross_hbox
Definition dlp_edit.c:113
G_MODULE_EXPORT void changed_cross_combo(GtkComboBox *box, gpointer data)
change field cross combo
Definition dlp_edit.c:449
GtkWidget * p_box
Definition dlp_edit.c:112
G_MODULE_EXPORT void field_molecule_select_atom_id(GtkCellRendererToggle *cell_renderer, gchar *string_path, gpointer data)
on select atom in field molecule toggle callback
Definition dlp_edit.c:922
gboolean body_identicals(field_nth_body *body, int nbd, int *na, int **ma, int **ba)
are these non bonded potentials identicals ?
Definition dlp_edit.c:1952
void check_atom_for_updates()
check for parameters in the database to be used in the force field - creating the dialog
G_MODULE_EXPORT void shell_in_vdw(GtkToggleButton *but, gpointer data)
VdW in shell toggle callback GTK3.
Definition dlp_edit.c:2220
gchar * field_str(int a)
get field external name
Definition dlp_edit.c:648
G_MODULE_EXPORT void run_edit_parameters(GtkDialog *dialog, gint response_id, gpointer data)
edit field parameter - running the dialog
Definition dlp_edit.c:2239
int num_body_d
Definition dlp_edit.c:419
double *** cross
Definition dlp_edit.c:418
G_MODULE_EXPORT void visualize_it(GtkToggleButton *but, gpointer data)
visualize object toggle callback GTK3
Definition dlp_edit.c:839
void visualize_body(int viz, int bd, field_nth_body *body)
show / hide non bonded interaction
Definition dlp_viz.c:339
GtkWidget * ff_p_combo[2]
int active_sel
Definition dlp_atom.c:54
GtkWidget * cross_box
Definition dlp_edit.c:417
void init_default_shaders(glwin *view)
re-initialize the default OpenGL shaders
GtkWidget * av_lgt
Definition dlp_edit.c:1599
G_MODULE_EXPORT void changed_field_key_combo(GtkComboBox *box, gpointer data)
change field key
Definition dlp_edit.c:740
char *** ff_atoms
GtkWidget * cross_vbox
Definition dlp_edit.c:113
void clean_up_molecules_info(gboolean usel)
prepare molecule related widgets in the assistant
Definition dlp_mol.c:124
void edit_parameters(int f, int id)
edit field parameter - creating the dialog
Definition dlp_edit.c:2266
gchar * get_body_element_name(field_nth_body *body, int aid, int nbd)
get field body potential element name
Definition dlp_edit.c:1926
int vdw_id
Definition dlp_edit.c:911
G_MODULE_EXPORT void update_cross_parameter(GtkEntry *res, gpointer data)
update field cross parameter entry callback
Definition dlp_edit.c:430
char * fvars_bond[2][FBONDS][FBONDS_P]
Definition dlp_field.c:306
char * fvars_inversion[2][FINVERS][FINVERS_P]
Definition dlp_field.c:522
char * fvars_dihedral[2][FDIHEDRAL][FDIHEDRAL_P]
Definition dlp_field.c:450
char * fvars_angle[2][FANGLES][FANGLES_P]
Definition dlp_field.c:372
char * fvars_vdw[2][FVDW][FVDW_P]
Definition dlp_field.c:602
GtkTreeIter field_iter
Definition dlp_field.c:948
char * fvars_fbd[2][FFOURBODY][FFOURBODY_P]
Definition dlp_field.c:762
glwin * tmp_view
Definition dlp_field.c:952
field_constraint * tmp_fcons
Definition dlp_field.c:959
int fvalues[2][15][21]
Definition dlp_field.c:255
int field_object
Definition dlp_field.c:979
field_nth_body * tmp_fbody
Definition dlp_field.c:965
project * tmp_proj
Definition dlp_field.c:953
field_shell * tmp_fshell
Definition dlp_field.c:958
field_rigid * tmp_frig
Definition dlp_field.c:961
int body_at(int b)
find the number of atom(s) in a non bonded interaction
Definition dlp_field.c:1022
int num_field_objects
Definition dlp_field.c:981
field_pmf * tmp_fpmf
Definition dlp_field.c:960
gchar * fnames[2][16][21]
Definition dlp_field.c:218
field_external * tmp_fext
Definition dlp_field.c:967
field_atom * tmp_fat
Definition dlp_field.c:957
int row_id
Definition dlp_field.c:982
GtkTreeStore * field_model[MAXDATA]
Definition dlp_field.c:947
char * fvars_ters[2][FTERSOFFS][FTERSOFFS_P]
Definition dlp_field.c:726
int struct_id(int f)
number of atoms in a structural element
Definition dlp_field.c:999
void update_field_trees()
classical force field assistant update all tree models
Definition dlp_field.c:1782
field_struct * tmp_fstr
Definition dlp_field.c:964
field_molecule * tmp_fmol
Definition dlp_field.c:955
field_prop * tmp_fprop
Definition dlp_field.c:963
char * fvars_tbd[2][FTHREEBODY][FTHREEBODY_P]
Definition dlp_field.c:736
field_tethered * tmp_ftet
Definition dlp_field.c:962
GType col_type[MAXDATA][12]
Definition dlp_field.c:856
GtkWidget * field_assistant
Definition dlp_field.c:940
gchar * fkeysw[2][16][21]
Definition dlp_field.c:185
classical_field * tmp_field
Definition dlp_field.c:951
char * fvars_fext[2][FEXTERNAL][FEXTERNAL_P]
Definition dlp_field.c:776
GtkWidget * combo_mol[MOLIMIT-1]
Definition dlp_field.c:944
char * fvars_met[2][FMETALS][FMETALS_P]
Definition dlp_field.c:688
char * fvars_teth[2][FTETH][FTETH_P]
Definition dlp_field.c:292
Variable declarations for the creation of the DL_POLY input file(s)
field_shell * init_field_shell(int id, int ia, int ib)
initialize field core shell interaction
Definition dlp_init.c:394
field_tethered * init_field_tethered(int id, int num)
initialize new field tethered potential
Definition dlp_init.c:510
#define COMPASS
Definition dlp_field.h:138
int * duplicate_int(int num, int *old_val)
copy a list of int
Definition global.c:560
#define CFF91
Definition dlp_field.h:136
float get_force_field_atom_mass(int sp, int num)
get force field atomic mass
#define MOLIMIT
Definition dlp_field.h:117
tint toviz
Definition dlp_viz.c:75
field_prop * init_field_prop(int ti, int key, gboolean show, gboolean use)
initialize new field molecule structural property
Definition dlp_init.c:535
#define CVFF
Definition dlp_field.h:134
#define CVFF_AUG
Definition dlp_field.h:135
char * field_acro[N_FIELDS]
field_pmf * init_field_pmf(int id, int num[2], int *list[2], float *w[2])
initialize new field mean force potential
Definition dlp_init.c:445
float * duplicate_float(int num, float *old_val)
copy a list of float
Definition global.c:592
#define SEXTERN
Definition dlp_field.h:118
#define AMBER99
Definition dlp_field.h:123
void visualize_object(int id, int jd, int kd)
visualize object and update OpenGL rendering
Definition dlp_viz.c:550
field_external * init_field_external(int bi)
initialize new field external potential
Definition dlp_init.c:790
field_constraint * init_field_constraint(int id, int ia, int ib)
initialize field bond constraint
Definition dlp_init.c:419
field_nth_body * init_field_nth_body(int bi, int bd, int *na, int **ma, int **ba)
initialize new field non bonded interaction
Definition dlp_init.c:740
field_rigid * init_field_rigid(int id, int num, int *list)
initialize new field rigid constraint
Definition dlp_init.c:487
int ff_unit
distance distance_3d(cell_info *cell, int mdstep, atom *at, atom *bt)
distance between atom a and b in 3D
Definition ogl_utils.c:81
int multi
Definition dlp_init.c:121
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:330
double * duplicate_double(int num, double *old_val)
copy a list of double
Definition global.c:608
int dialog_id
Definition global.c:167
int activef
Definition global.c:161
GMainLoop * Event_loop[5]
Definition global.c:178
double *** alloctdouble(int xal, int yal, int zal)
allocate a double *** pointer
Definition global.c:498
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
float * allocfloat(int val)
allocate a float * pointer
Definition global.c:398
double string_to_double(gpointer string)
convert string to double
Definition global.c:624
Global variable declarations Global convenience function declarations Global data structure defin...
void run_this_gtk_dialog(GtkWidget *dial, GCallback handler, gpointer data)
run a GTK (3 and 4) basic GtkDialog
Definition gtk-misc.c:501
@ IMG_NONE
Definition global.h:262
int combo_get_active(GtkWidget *combo)
retrieve the active item's position
Definition gtk-misc.c:909
GtkWidget * create_entry(GCallback handler, int dim, int cdim, gboolean key_release, gpointer data)
Create a GtkEntry.
Definition gtk-misc.c:1375
void update_entry_double(GtkEntry *entry, double doubleval)
update the content of a GtkEntry as double
Definition gtk-misc.c:643
void set_renderer_color(int tocol, GtkCellRenderer *renderer, ColRGBA col)
set the color of a GtkCellRenderer
Definition gtk-misc.c:1714
GtkWidget * create_scroll(GtkWidget *box, int dimx, int dimy, int shadow)
create a scroll window
Definition gtk-misc.c:2095
GtkWidget * dialogmodal(gchar *str, GtkWindow *parent)
Create a new dialog modal window.
Definition gtk-misc.c:520
void combo_set_active(GtkWidget *combo, int pos)
set the active item's position
Definition gtk-misc.c:932
const gchar * entry_get_text(GtkEntry *entry)
get the text in a GtkEntry
Definition gtk-misc.c:607
#define BSEP
Definition global.h:247
GtkWidget * stock_image(const gchar *stock_id)
create a GtkImage for the Gtk database
Definition gtk-misc.c:1425
#define APPLY
Definition global.h:222
GtkWidget * check_button(gchar *text, int dimx, int dimy, gboolean state, GCallback handler, gpointer data)
create a check button
Definition gtk-misc.c:1893
@ CONTAINER_SCR
Definition global.h:253
GtkWidget * create_button(gchar *text, int image_format, gchar *image, int dimx, int dimy, int relief, GCallback handler, gpointer data)
create a simple button
Definition gtk-misc.c:1955
GtkWidget * create_combo()
create a GtkCombox widget, note deprecated in GTK4
Definition gtk-misc.c:984
GtkWidget * dialog_get_content_area(GtkWidget *widg)
prepare GtkWidget to insert content in a GtkDialog window
Definition gtk-misc.c:835
GtkWidget * markup_label(gchar *text, int dimx, int dimy, float ax, float ay)
create a GtkLabel with pango markup
Definition gtk-misc.c:1646
void add_box_child_start(int orientation, GtkWidget *widg, GtkWidget *child, gboolean expand, gboolean fill, int padding)
Add a GtkWidget in a GtkBox at the initial position.
Definition gtk-misc.c:308
#define DELETEB
Definition global.h:224
void widget_set_sensitive(GtkWidget *widg, gboolean sensitive)
Set sensitivity for a GtkWidget, ensuring it is a GtkWidget.
Definition gtk-misc.c:215
void destroy_this_dialog(GtkDialog *dialog)
destroy a GtkDialog
Definition gtk-misc.c:2200
GtkWidget * create_hbox(int spacing)
create a GtkBox with horizontal orientation
Definition gtk-misc.c:823
#define CHEM_M
Definition global.h:300
void combo_text_append(GtkWidget *combo, gchar *text)
append text in GtkComboBox widget
Definition gtk-misc.c:961
GtkWidget * destroy_this_widget(GtkWidget *widg)
destroy a GtkWidget
Definition gtk-misc.c:2169
void update_entry_text(GtkEntry *entry, gchar *text)
update the content of a GtkEntry as string
Definition gtk-misc.c:681
void add_container_child(int type, GtkWidget *widg, GtkWidget *child)
Add a GtkWidget into another GtkWidget.
Definition gtk-misc.c:235
void set_image_from_icon_name(GtkWidget *widg, gchar *icon)
set a image from a stock icon name
Definition gtk-misc.c:1986
void hide_the_widgets(GtkWidget *widg)
hide GtkWidget
Definition gtk-misc.c:198
GtkWidget * create_vbox(int spacing)
create a GtkBox with vertical orientation
Definition gtk-misc.c:811
int button_get_status(GtkWidget *button)
get status of check / toggle button
Definition gtk-misc.c:1855
#define MAXDATA
Number of tabs for the description of the classical force field.
Definition global.h:703
void show_the_widgets(GtkWidget *widg)
show GtkWidget
Definition gtk-misc.c:182
Variable declarations related to the OpenGL window Function declarations related to the OpenGL wind...
action
Definition glview.h:198
Function declarations for the creation of the OpenGL window.
gchar * cask(char *question, char *lab, int id, char *old, GtkWidget *win)
enter a string - prepare the dialog
Definition interface.c:706
gboolean ask_yes_no(gchar *title, gchar *text, int type, GtkWidget *widg)
ask yes or no for something: prepare dialog
Definition interface.c:356
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
Messaging function declarations.
integer(kind=c_int) function molecules(frag_and_mol, allbonds)
double z
Definition ogl_draw.c:61
Definition global.h:891
double z
Definition global.h:897
double y
Definition global.h:896
double x
Definition global.h:895
Definition glwin.h:351
Definition global.h:99
int b
Definition global.h:101
int a
Definition global.h:100
double length
Definition glwin.h:124
Definition glwin.h:965
int c
Definition global.h:109
int a
Definition tab-1.c:95
GtkWidget * res[2]
Definition w_encode.c:212
int element
Definition w_periodic.c:61
GtkWidget * hbox
Definition workspace.c:71
GtkWidget * vbox
Definition workspace.c:72
GtkWidget * lab
Definition workspace.c:73