atomes 1.1.15
atomes: an atomic scale modeling tool box
Loading...
Searching...
No Matches
force_fields.c
Go to the documentation of this file.
1/* This file is part of the 'atomes' software
2
3'atomes' is free software: you can redistribute it and/or modify it under the terms
4of the GNU Affero General Public License as published by the Free Software Foundation,
5either version 3 of the License, or (at your option) any later version.
6
7'atomes' is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
8without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9See the GNU General Public License for more details.
10
11You should have received a copy of the GNU Affero General Public License along with 'atomes'.
12If not, see <https://www.gnu.org/licenses/>
13
14Copyright (C) 2022-2024 by CNRS and University of Strasbourg */
15
23/*
24* This file: 'force_fields.c'
25*
26* Contains:
27*
28
29 - The functions to prepare the force field XML files from the sources in atomes
30 - The functions to read the force field XML files
31
32*
33* List of functions:
34
35 int get_pdim(int fid, int prop, int col);
36 int get_fkey(int fid, int prop, int col);
37 int find_atom_id (int print, char * keyw);
38 int find_atom_z (char * keyw);
39 int get_z (int faid);
40 int get_atoms (int z);
41 int get_bond (int faid, int bid);
42 int get_angle (int faid, int aid);
43 int get_apex (int faid, int aid);
44 int get_torsion (int faid, int tid, int a, int b);
45 int get_improper (int faid, int a, int b);
46 int get_vdw (int faid);
47 int get_bi (int faid);
48 int field_find_atoms ();
49
50 float get_force_field_atom_mass (int sp, int num);
51
52 gboolean not_done (int eid, int a, int b);
53 gboolean not_done_an (int eid, int a, int b, int c);
54 gboolean is_a_match (int * data, int num, int val[4]);
55
56 gchar * find_atom_key (int fid, int prop, char * keyw);
57 gchar * open_field_file (int field);
58
59 void associate_pointers_to_field_data (int id);
60 void print_object_dim_and_key_tables (int fid);
61 void set_data (int pid, int obj, int oid, int faid);
62 void field_has_element (int aid);
63 void print_atom_table (int fid);
64 void print_this_bond (int eid, int h, int fid, int inum, char * at_a, char * at_b, char ** the_bond);
65 void print_bond_table (int fid, int inum);
66 void print_this_angle (int eid, int h, int fid, int inum, int ub, char * at_a, char * at_b, char * at_c, char ** the_angle);
67 void print_angle_table (int fid, int inum);
68 void print_dihedral_table (int fid, int inum);
69 void print_improper_table (int fid, int inum);
70 void print_inversion_table (int fid, int inum);
71 void print_vdw_table (int fid, int inum);
72 void find_object_ijkl (int hid, int foid, int oid, int sa, int za, int sb, int zb, int sc, int zc, int sd, int zd);
73 void field_find_bonds ();
74 void field_find_angles ();
75 void field_find_dihedrals (int id);
76 void field_find_vdw ();
77 void print_all (int oid);
78 void clean_this_field_data (xmlDoc * doc, xmlTextReaderPtr reader);
79
80 G_MODULE_EXPORT void setup_this_force_field (int id);
81
82*/
83
84#include "global.h"
85#include "interface.h"
86#include "dlp_field.h"
87#include "force_fields.h"
88#include <libxml/xmlreader.h>
89
90extern xmlNodePtr findnode (xmlNodePtr startnode, char * nname);
91extern int clean_xml_data (xmlDoc * doc, xmlTextReaderPtr reader);
92
93#define N_FIELDS 21
94#define N_PARAMS
95#define ALL_PARAMS 9
96
97// Define Fields order and id
98
99#define FATS 0
100#define FEQI 1
101#define FBDS 2
102#define FANG 3
103#define FDIH 4
104#define FIMP 5
105#define FINV 6
106#define FNBD 7
107#define FINC 8
108
109#define USE_ATOMS
110
111/*
112
113AMBER*: In atoms check label (1 letter only)
114
115CHARMM*: In atoms check label (1 letter only)
116
117CVFF/CVFF_aug/CFF91/PCFF:
118 - Bonds: 'c=_' in 'c=', 'n=_' in 'n=', 'd_' in 'dw', 'ci_' in 'ci', 'ni_' in 'ni'
119 - Quadratic angles: 's3m_' in 's3e_', 's4m_' in 's4e_', 'o4m_' in 'o4e_', '*?' in '*'
120
121CVFF:
122 - Atoms: 'mg' in 'Mg'
123
124CVFF_aug:
125 - Non-bonded : 'Al' in 'al'
126
127Compass :
128
129OPLSAA?:
130 - In atoms : 'NA' to 'Na', 'CLA' to 'Cl', 'MG' to 'Mg'
131
132*/
133
134char * field_keyw[N_FIELDS] = {"amber94",
135 "amber96",
136 "amber98",
137 "amber99",
138 "prot_22",
139 "prot_metals_22",
140 "ethers_35",
141 "carb_36",
142 "cgenff_36",
143 "lipid_36",
144 "na_36",
145 "prot_36",
146 "prot_metals_36",
147 "silicates",
148 "CVFF",
149 "CVFF_Aug",
150 "CFF91",
151 "PCFF",
152 "Compass",
153 "OPLSAAP",
154 "OPLSAAR"};
155
156char * field_ffl[N_FIELDS] = {"amber94",
157 "amber96",
158 "amber98",
159 "amber99",
160 "charmm-prot_22",
161 "charmm-prot_metals_22",
162 "charmm-ethers_35",
163 "charmm-carb_36",
164 "charmm-cgenff_36",
165 "charmm-lipid_36",
166 "charmm-na_36",
167 "charmm-prot_36",
168 "charmm-prot_metals_36",
169 "charmm-silicates",
170 "cvff",
171 "cvff_aug",
172 "cff91",
173 "pcff",
174 "compass",
175 "oplsaap",
176 "oplsaar"};
177
178char * field_name[N_FIELDS] = {"Assisted Model Building with Energy Refinement 94",
179 "Assisted Model Building with Energy Refinement 96",
180 "Assisted Model Building with Energy Refinement 98",
181 "Assisted Model Building with Energy Refinement 99",
182 "Chemistry at HARvard Macromolecular Mechanics 22 Proteins",
183 "Chemistry at HARvard Macromolecular Mechanics 22 Proteins and metals",
184 "Chemistry at HARvard Macromolecular Mechanics 35 Ethers",
185 "Chemistry at HARvard Macromolecular Mechanics 36 Carbohydrates",
186 "Chemistry at HARvard Macromolecular Mechanics 36 General",
187 "Chemistry at HARvard Macromolecular Mechanics 36 Lipids",
188 "Chemistry at HARvard Macromolecular Mechanics 36 Nucleid acids",
189 "Chemistry at HARvard Macromolecular Mechanics 36 Proteins",
190 "Chemistry at HARvard Macromolecular Mechanics 36 proteins and metals",
191 "Chemistry at HARvard Macromolecular Mechanics Silicates",
192 "Consistent Valence Force Field",
193 "Consistent Valence Force Field Augmented",
194 "Consistent Force Field 91",
195 "Polymer Consistent Force Field",
196 "Condensed-phase Optimized Molecular Potentials for Atomistic Simulation Studies",
197 "Optimized Potentials for Liquid Simulation All-atoms for Proteins",
198 "Optimized Potentials for Liquid Simulation All-atoms for Proteins, Nucleosides, and Nucleotides"};
199
200char * field_acro[N_FIELDS] = {"AMBER 94",
201 "AMBER 96",
202 "AMBER 98",
203 "AMBER 99",
204 "CHARMM 22 Proteins",
205 "CHARMM 22 Proteins and metals",
206 "CHARMM 35 Ethers",
207 "CHARMM 36 Carbohydrates",
208 "CHARMM 36 General",
209 "CHARMM 36 Lipids",
210 "CHARMM 36 Nucleid acids",
211 "CHARMM 36 Proteins",
212 "CHARMM 36 Proteins and metals",
213 "CHARMM Silicates",
214 "CVFF",
215 "CVFF Augmented",
216 "CFF 91",
217 "PCFF",
218 "COMPASS",
219 "OPLS All-atoms for proteins",
220 "OPLS All-atoms for RNA"};
221
222char *** field_atoms;
223char *** field_equi[2];
224// 0 = Quadratic, 1 = Quartic, 2 = Morse
225char *** field_bonds[3];
226// 0 = Quadratic, 1 = Quartic
227char *** field_angles[2];
228char *** field_dihedrals[2];
231char *** field_vdw;
232
235
236gboolean is_99;
237
241
242FILE * fp;
243
244gchar * ffo_file[21]={"parm94.dat", "parm96.dat", "parm98.dat", "parm99.dat",
245 "par_all22_prot.prm", "par_all22_prot_metals.prm", "par_all35_ethers.prm",
246 "par_all36_carb.prm", "par_all36_cgenff.prm", "par_all36_lipid.prm", "par_all36_na.prm",
247 "par_all36_prot.prm", "par_all36m_prot.prm", "par_all_silicates.prm",
248 "CVFF.frc", "CVFF_aug.frc", "CFF91.frc", "PCFF.frc", "compass.frc", "par_opls_aam.inp", "par_opls_rna.inp"};
249
250gchar * prop_name[11]= {"Quadratic bonds", "Quartic bonds", "Morse bonds", "Quadratic angles", "Quartic angles",
251 "Dihedrals", "Torsions 3", "Inversions", "Impropers", "Non-bonded", "Bond increments"};
252
253gchar * table_name[11]= {"qbonds", "sbonds", "mbonds", "qangles", "sangles", "dih", "tor", "inv", "imp", "vdw", "bdi"};
254
255int ffdim[14][2] = {{1, 0}, {1, 1}, {1, 1}, {2, 2}, {2, 4}, {2, 3}, {3, 2}, {3, 4}, {4, 3}, {4, 4}, {4, 2}, {4, 3}, {1, 2}, {2, 0}};
256// Pot +1 ou (-Pot+1) si special
257int ffpot[N_FIELDS][10]={{1, 0, 0, 1, 0, 1, 0, 1, 0, 1},
258 {1, 0, 0, 1, 0, 1, 0, 1, 0, 1},
259 {1, 0, 0, 1, 0, 1, 0, 1, 0, 1},
260 {1, 0, 0, 1, 0, 1, 0, 1, 0, 1},
261 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
262 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
263 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
264 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
265 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
266 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
267 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
268 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
269 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
270 {1, 0, 0, -1, 0, 1, 0, 2, 0, -1},
271 {1, 0, 2, 1, 0, 1, -4, 1, 0, 1},
272 {1, 0, 2, 1, 0, 1, -4, 1, 0, 0},
273 {1, 6, 0, 0, 2, 1, -4, 0, 2, 0},
274 {1, 6, 0, 1, 2, 1, -4, 0, 2, 0},
275 {0, 6, 0, 0, 2, 0, -4, 0, 2, -2},
276 {1, 0, 0, 1, 0, 1, 0, 1, 0, 1},
277 {1, 0, 0, 1, 0, 1, 0, 1, 0, 1}};
278
279
289int get_pdim(int fid, int prop, int col)
290{
291 if (prop == 0) return field_dim[0];
292 if (field_dim[prop] == 0) return 0;
293 if (prop == 6 && col == 1 && (fid >= CHARMM22P && fid <= CHARMMSI)) return 4;
294 if (prop == 12 && col == 1 && ((fid >= CHARMM22P && fid <= CHARMMSI) || (fid >= OPLSAAP))) return 4;
295 return ffdim[prop][col];
296}
297
307int get_fkey(int fid, int prop, int col)
308{
309 return ffdim[prop][col];
310}
311
312#ifndef USE_ATOMS
313void allocate_field_data (int * objects, int * dim,
314 char * atoms[objects[0]][dim[0]], char * equi_a[objects[1]][dim[1]], char * equi_b[objects[2]][dim[2]],
315 char * bonds[objects[3]][dim[3]], char * q_bonds[objects[4]][dim[4]], char * m_bonds[objects[5]][dim[5]],
316 char * angles[objects[6]][dim[6]], char * q_angles[objects[7]][dim[7]],
317 char * dihedrals[objects[8]][dim[8]], char * q_dihedrals[objects[9]][dim[9]],
318 char * inversions[objects[10]][dim[10]], char * impropers[objects[11]][dim[11]],
319 char * vdw[objects[12]][dim[12]], char * bond_inc[objects[13]][dim[13]])
320
321{
322 int h, i;
324 field_dim = dim;
325 field_atoms = g_malloc (field_objects[0]*sizeof*field_atoms);
326 for (i=0; i<field_objects[0]; i++)
327 {
328 field_atoms[i] = g_malloc (field_dim[0]*sizeof*field_atoms[i]);
329 field_atoms[i] = atoms[i];
330 }
331 for (h=0; h<2; h++)
332 {
333 if (field_objects[1+h])
334 {
335 field_equi[h] = g_malloc (field_objects[1+h]*sizeof*field_equi[h]);
336 for (i=0; i<field_objects[1+h]; i++)
337 {
338 field_equi[h][i] = g_malloc (field_dim[h+1]*sizeof*field_equi[h][i]);
339 switch (h)
340 {
341 case 0:
342 field_equi[h][i] = equi_a[i];
343 break;
344 case 1:
345 field_equi[h][i] = equi_b[i];
346 break;
347 }
348 }
349 }
350 }
351 for (h=0; h<3; h++)
352 {
353 if (field_objects[3+h])
354 {
355 field_bonds[h] = g_malloc (field_objects[3+h]*sizeof*field_bonds[h]);
356 for (i=0; i<field_objects[3+h]; i++)
357 {
358 field_bonds[h][i] = g_malloc (field_dim[3+h]*sizeof*field_bonds[h][i]);
359 switch (h)
360 {
361 case 0:
362 field_bonds[h][i] = bonds[i];
363 break;
364 case 1:
365 field_bonds[h][i] = q_bonds[i];
366 break;
367 case 2:
368 field_bonds[h][i] = m_bonds[i];
369 break;
370 }
371 }
372 }
373 else
374 {
375 field_bonds[h] = NULL;
376 }
377 }
378 for (h=0; h<2; h++)
379 {
380 if (field_objects[6+h])
381 {
382 field_angles[h] = g_malloc (field_objects[6+h]*sizeof*field_angles[h]);
383 for (i=0; i<field_objects[6+h]; i++)
384 {
385 field_angles[h][i] = g_malloc (field_dim[6+h]*sizeof*field_angles[h][i]);
386 switch (h)
387 {
388 case 0:
389 field_angles[h][i] = angles[i];
390 break;
391 case 1:
392 field_angles[h][i] = q_angles[i];
393 break;
394 }
395 }
396 }
397 else
398 {
399 field_angles[h] = NULL;
400 }
401 }
402 for (h=0; h<2; h++)
403 {
404 if (field_objects[8+h])
405 {
406 field_dihedrals[h] = g_malloc (field_objects[8+h]*sizeof*field_dihedrals[h]);
407 for (i=0; i<field_objects[8+h]; i++)
408 {
409 field_dihedrals[h][i] = g_malloc (field_dim[8+h]*sizeof*field_dihedrals[h][i]);
410 switch (h)
411 {
412 case 0:
413 field_dihedrals[h][i] = dihedrals[i];
414 break;
415 case 1:
416 field_dihedrals[h][i] = q_dihedrals[i];
417 break;
418 }
419 }
420 }
421 else
422 {
423 field_dihedrals[h] = NULL;
424 }
425 }
426
427 if (field_objects[10])
428 {
429 field_inversions = g_malloc (field_objects[10]*sizeof*field_inversions);
430 for (i=0; i<field_objects[10]; i++)
431 {
432 field_inversions[i] = g_malloc (field_dim[10]*sizeof*field_inversions[i]);
433 field_inversions[i] = inversions[i];
434 }
435 }
436 else
437 {
438 field_inversions = NULL;
439 }
440
441
442 if (field_objects[11])
443 {
444 field_impropers = g_malloc (field_objects[11]*sizeof*field_impropers);
445 for (i=0; i<field_objects[11]; i++)
446 {
447 field_impropers[i] = g_malloc (field_dim[11]*sizeof*field_impropers[i]);
448 field_impropers[i] = impropers[i];
449 }
450 }
451 else
452 {
453 field_impropers = NULL;
454 }
455
456
457 if (field_objects[12])
458 {
459 field_vdw = g_malloc (field_objects[12]*sizeof*field_vdw);
460 for (i=0; i<field_objects[12]; i++)
461 {
462 field_vdw[i] = g_malloc (field_dim[12]*sizeof*field_vdw[i]);
463 field_vdw[i] = vdw[i];
464 }
465 }
466 else
467 {
468 field_vdw = NULL;
469 }
470}
471
479void associate_pointers_to_field_data (int id)
480{
481 switch (id)
482 {
483 case AMBER94:
484 allocate_field_data ((int *)amber94_objects, (int *)amber94_dim, amber94_atoms, amber94_equi, NULL,
485 amber94_bonds, NULL, NULL, amber94_angles, NULL,
487 break;
488 case AMBER96:
489 allocate_field_data ((int *)amber96_objects, (int *)amber96_dim, amber96_atoms, amber96_equi, NULL,
490 amber96_bonds, NULL, NULL, amber96_angles, NULL,
492 break;
493 case AMBER98:
494 allocate_field_data ((int *)amber98_objects, (int *)amber98_dim, amber98_atoms, amber98_equi, NULL,
495 amber98_bonds, NULL, NULL, amber98_angles, NULL,
497 break;
498 case AMBER99:
499 allocate_field_data ((int *)amber99_objects, (int *)amber99_dim, amber99_atoms, amber99_equi, NULL,
500 amber99_bonds, NULL, NULL, amber99_angles, NULL,
502 break;
503 case CHARMM22P:
504 allocate_field_data ((int *)charmm22_prot_objects, (int *)charmm22_prot_dim, charmm22_prot_atoms, NULL, NULL,
505 charmm22_prot_bonds, NULL, NULL, charmm22_prot_angles, NULL,
507 break;
508 case CHARMM22M:
509 allocate_field_data ((int *)charmm22_prot_metals_objects, (int *)charmm22_prot_metals_dim, charmm22_prot_metals_atoms, NULL, NULL,
512 break;
513 case CHARMM35E:
514 // No impropers
515 allocate_field_data ((int *)charmm35_ethers_objects, (int *)charmm35_ethers_dim, charmm35_ethers_atoms, NULL, NULL,
517 charmm35_ethers_dihedrals, NULL, NULL, NULL, charmm35_ethers_vdw, NULL);
518 break;
519 case CHARMM36C:
520 allocate_field_data ((int *)charmm36_carb_objects, (int *)charmm36_carb_dim, charmm36_carb_atoms, NULL, NULL,
521 charmm36_carb_bonds, NULL, NULL, charmm36_carb_angles, NULL,
523 break;
524 case CHARMM36G:
525 allocate_field_data ((int *)charmm36_cgenff_objects, (int *)charmm36_cgenff_dim, charmm36_cgenff_atoms, NULL, NULL,
528 break;
529 case CHARMM36L:
530 allocate_field_data ((int *)charmm36_lipid_objects, (int *)charmm36_lipid_dim, charmm36_lipid_atoms, NULL, NULL,
533 break;
534 case CHARMM36N:
535 allocate_field_data ((int *)charmm36_na_objects, (int *)charmm36_na_dim, charmm36_na_atoms, NULL, NULL,
536 charmm36_na_bonds, NULL, NULL, charmm36_na_angles, NULL,
538 break;
539 case CHARMM36P:
540 allocate_field_data ((int *)charmm36_prot_objects, (int *)charmm36_prot_dim, charmm36_prot_atoms, NULL, NULL,
541 charmm36_prot_bonds, NULL, NULL, charmm36_prot_angles, NULL,
543 break;
544 case CHARMM36M:
545 allocate_field_data ((int *)charmm36m_prot_objects, (int *)charmm36m_prot_dim, charmm36m_prot_atoms, NULL, NULL,
548 break;
549 case CHARMMSI:
550 // No impropers
551 allocate_field_data ((int *)charmm_silicates_objects, (int *)charmm_silicates_dim, charmm_silicates_atoms, NULL, NULL,
553 charmm_silicates_dihedrals, NULL, NULL, NULL, charmm_silicates_vdw, NULL);
554 break;
555 case CVFF:
556 allocate_field_data ((int *)CVFF_objects, (int *)CVFF_dim, CVFF_atoms, CVFF_equivalence_auto, CVFF_equivalence,
558 CVFF_torsions_auto, NULL, NULL, CVFF_impropers, CVFF_vdw, NULL);
559 break;
560 case CVFF_AUG:
564 break;
565 case CFF91:
566 allocate_field_data ((int *)CFF91_objects, (int *)CFF91_dim, CFF91_atoms, CFF91_equivalence_auto, CFF91_equivalence,
569 break;
570 case PCFF:
571 allocate_field_data ((int *)PCFF_objects, (int *)PCFF_dim, PCFF_atoms, PCFF_equivalence_auto, PCFF_equivalence,
574 break;
575 case COMPASS:
576 allocate_field_data ((int *)Compass_objects, (int *)Compass_dim, Compass_atoms, NULL, Compass_equivalence,
577 NULL, Compass_bonds, NULL, NULL, Compass_angles,
579 break;
580 case OPLSAAP:
581 allocate_field_data ((int *)OPLSAAM_objects, (int *)OPLSAAM_dim, OPLSAAM_atoms, NULL, NULL,
582 OPLSAAM_bonds, NULL, NULL, OPLSAAM_angles, NULL,
584 break;
585 case OPLSAAR:
586 allocate_field_data ((int *)OPLSAAR_objects, (int *)OPLSAAR_dim, OPLSAAR_atoms, NULL, NULL,
587 OPLSAAR_bonds, NULL, NULL, OPLSAAR_angles, NULL,
589 break;
590 default:
591 field_objects = NULL;
592 field_atoms = NULL;
593 field_bonds[0] = field_bonds[1] = field_bonds[2]= NULL;
594 field_angles[0] = field_angles[1] = NULL;
595 field_dihedrals[0] = field_dihedrals[1] = NULL;
596 field_inversions = NULL;
597 field_impropers = NULL;
598 field_vdw = NULL;
599 break;
600 }
601}
602#endif
603
612int find_atom_id (int print, char * keyw)
613{
614 int i;
615 for (i=0; i<field_objects[0]; i++)
616 {
617 if (g_strcmp0 (keyw, field_atoms[i][2]) == 0) return i;
618 }
619 if (g_strcmp0 (keyw, "X") == 0) return -1;
620 if (g_strcmp0 (keyw, "*") == 0) return -1;
621#ifdef DEBUG
622 if (print) g_debug ("ID:: -10:: key= '%s'", keyw);
623#endif
624 return -10;
625}
626
636gchar * find_atom_key (int fid, int prop, char * keyw)
637{
638 if (fid > CHARMMSI && fid < OPLSAAP)
639 {
640 if (find_atom_id(0, keyw) == -10)
641 {
642 int i;
643 for (i=0; i<field_objects[2]; i++)
644 {
645 if (g_strcmp0 (keyw, field_equi[1][i][prop]) == 0) return field_equi[1][i][0];
646 }
647 for (i=0; i<field_objects[1]; i++)
648 {
649 if (g_strcmp0 (keyw, field_equi[0][i][prop+prop/2+prop/5]) == 0) return field_equi[0][i][0];
650 }
651 if (prop > 2)
652 {
653 for (i=0; i<field_objects[1]; i++)
654 {
655 if (g_strcmp0 (keyw, field_equi[0][i][prop+prop/2+prop/5+1]) == 0) return field_equi[0][i][0];
656 }
657 }
658#ifdef DEBUG
659 g_debug ("Nothing found in equi:: prop= %d, keyw= %s", prop, keyw);
660#endif
661 }
662 return keyw;
663 }
664 else
665 {
666 return keyw;
667 }
668}
669
677int find_atom_z (char * keyw)
678{
679 int i, j;
680 for (i=0; i<field_objects[0]; i++)
681 {
682 if (g_strcmp0 (keyw, field_atoms[i][2]) == 0)
683 {
684 for (j=1; j<120; j++)
685 {
686 if (g_strcmp0 (periodic_table_info[j].lab, field_atoms[i][0]) == 0) return periodic_table_info[j].Z;
687 //if (g_strcmp0 (exact_name(periodic_table_info[j].lab), exact_name(field_atoms[i][0])) == 0) return periodic_table_info[j].Z;
688 }
689 }
690 }
691 if (g_strcmp0 (keyw, "X") == 0) return -1;
692 if (g_strcmp0 (keyw, "*") == 0) return -1;
693 if (g_strcmp0 (keyw, "L") == 0 || g_strcmp0 (keyw, "lp") == 0 || g_strcmp0 (keyw, "LP") == 0 || g_strcmp0 (keyw, "LPH") == 0) return -2;
694 if (g_strcmp0 (keyw, "EP") == 0) return -3;
695 if (g_strcmp0 (keyw, "DUM") == 0) return -4;
696#ifdef DEBUG
697 g_debug ("Z:: -10:: key= '%s'", keyw);
698#endif
699 return -10;
700}
701
710{
711 gchar * nodes[11]={"atoms", "bonds-h", "bonds-q", "bonds-m", "angles-h", "angles-q",
712 "dihedrals-c", "dihedrals-ccc", "impropers", "inversions", "non-bonded"};
713 fprintf (fp, " <ff-data>\n");
714 int i, j, k, l, n, m;
715 k = -1;
716 for (i=0; i<13; i++)
717 {
718 if (i != 1 && i != 2)
719 {
720 k ++;
721 j = (i == 10) ? 11 : (i == 11) ? 10 : i;
722 if (i == 0)
723 {
724 fprintf (fp, " <%s dim=\"%d\">%d</%s>\n", nodes[k], (field_objects[j]) ? get_pdim(fid, j, 1) : 0, field_objects[j], nodes[k]);
725 }
726 else if (i < 12)
727 {
728 fprintf (fp, " <%s dim=\"%d\" pot=\"%d\">%d</%s>\n", nodes[k], (field_objects[j]) ? get_pdim(fid, j, 1) : 0, ffpot[fid][k-1], field_objects[j], nodes[k]);
729 }
730 else
731 {
732 l = 0;
733 if (fid <= AMBER99)
734 {
735 for (n=0; n<field_objects[1]; n++)
736 {
737 for (m=1; m<field_dim[1]; m++)
738 {
739 if(g_strcmp0 (field_equi[0][n][m], " ") != 0)
740 {
741 l ++;
742 }
743 }
744 }
745 }
746 fprintf (fp, " <%s dim=\"%d\" pot=\"%d\">%d</%s>\n", nodes[k], (field_objects[j]) ? get_pdim(fid, j, 1) : 0, ffpot[fid][k-1], field_objects[j]+l, nodes[k]);
747 }
748 }
749 }
750 fprintf (fp, " </ff-data>\n");
751}
752
755
766void set_data (int pid, int obj, int oid, int faid)
767{
768 if (all_data[pid][faid] == NULL)
769 {
770 all_data[pid][faid] = g_malloc0 (sizeof*all_data[pid][faid]);
771 om_tmp = all_data[pid][faid];
772 }
773 else
774 {
775 om_tmp -> next = g_malloc0 (sizeof*om_tmp -> next);
776 om_tmp -> next -> id = om_tmp -> id + 1;
777 om_tmp -> next -> prev = om_tmp;
778 }
779 om_tmp -> obj = obj;
780 om_tmp -> oid = oid;
781}
782
790int get_z (int faid)
791{
792 int i;
793 for (i=0; i<120; i++)
794 {
795 if (g_strcmp0 (periodic_table_info[i].lab, field_atoms[faid][0]) == 0) return periodic_table_info[i].Z;
796 }
797 return -1;
798}
799
807int get_atoms (int z)
808{
809 int i, j;
810 j = 0;
811 for (i=0; i<field_objects[0]; i++)
812 {
813 if (get_z(i) == z)
814 {
815 set_data (0, 0, j, z);
816 j ++;
817 }
818 }
819 return j;
820}
821
830int get_bond (int faid, int bid)
831{
832 int i, j;
833 j = 0;
834 if (field_objects[3+bid])
835 {
836 for (i=0; i<field_objects[3+bid]; i++)
837 {
838 if ((g_strcmp0 (field_bonds[bid][i][0], field_atoms[faid][2]) == 0) || (g_strcmp0 (field_bonds[bid][i][1], field_atoms[faid][2]) == 0))
839 {
840 set_data (1, bid, i, faid);
841 j ++;
842 }
843 }
844 }
845 return j;
846}
847
856int get_angle (int faid, int aid)
857{
858 int i, j;
859 j = 0;
860 if (field_objects[6+aid])
861 {
862 for (i=0; i<field_objects[6+aid]; i++)
863 {
864 if ((g_strcmp0 (field_angles[aid][i][0], field_atoms[faid][2]) == 0) || (g_strcmp0 (field_angles[aid][i][2], field_atoms[faid][2]) == 0))
865 {
866 set_data (2, aid, i, faid);
867 j ++;
868 }
869 }
870 }
871 return j;
872}
873
882int get_apex (int faid, int aid)
883{
884 int i, j;
885 j = 0;
886 if (field_objects[6+aid])
887 {
888 for (i=0; i<field_objects[6+aid]; i++)
889 {
890 if (g_strcmp0 (field_angles[aid][i][1], field_atoms[faid][2]) == 0)
891 {
892 set_data (3, aid, i, faid);
893 j ++;
894 }
895 }
896 }
897 return j;
898}
899
910int get_torsion (int faid, int tid, int a, int b)
911{
912 int i, j;
913 j = 0;
914 if (field_objects[8+tid])
915 {
916 for (i=0; i<field_objects[8+tid]; i++)
917 {
918 if ((g_strcmp0 (field_dihedrals[tid][i][a], field_atoms[faid][2]) == 0) || (g_strcmp0 (field_dihedrals[tid][i][b], field_atoms[faid][2]) == 0))
919 {
920 set_data (4+a, tid, i, faid);
921 j ++;
922 }
923 }
924 }
925 return j;
926}
927
937int get_improper (int faid, int a, int b)
938{
939 int i, j;
940 j = 0;
941 if (field_objects[11])
942 {
943 for (i=0; i<field_objects[11]; i++)
944 {
945 if ((g_strcmp0 (field_impropers[i][a], field_atoms[faid][2]) == 0) || (g_strcmp0 (field_impropers[i][b], field_atoms[faid][2]) == 0))
946 {
947 set_data (6+a, 0, i, faid);
948 j ++;
949 }
950 }
951 }
952 return j;
953}
954
962int get_vdw (int faid)
963{
964 int i, j;
965 j = 0;
966 if (field_objects[12])
967 {
968 for (i=0; i<field_objects[12]; i++)
969 {
970 if (g_strcmp0 (field_vdw[i][0], field_atoms[faid][2]) == 0)
971 {
972 set_data (8, 0, i, faid);
973 j ++;
974 }
975 }
976 }
977 return j;
978}
979
1013void field_has_element (int aid)
1014{
1015 int h, i, j, k, l, m, n, o, p, q, r, s;
1016 j = k = l = m = n = o = p = q = r = s = 0;
1017 for (i=0; field_objects[0]; i++)
1018 {
1019 if (g_strcmp0 (periodic_table_info[aid].lab, field_atoms[i][0]) == 0)
1020 {
1021 j ++;
1022 for (h=0; h<3; h++) k += get_bond (i, h);
1023 for (h=0; h<2; h++) l += get_angle(i, h);
1024 for (h=0; h<2; h++) m += get_apex(i, h);
1025 for (h=0; h<2; h++) n += get_torsion (i, h, 0, 3);
1026 for (h=0; h<2; h++) o += get_torsion (i, h, 1, 2);
1027 p += get_improper (i, 0, 3);
1028 q += get_improper (i, 1, 2);
1029 r += get_vdw(i);
1030 //s += get_bi(i);
1031 }
1032 }
1033 // Number of objects by atomic number, 10 columns
1034 // 0 = Elem, 1 = Tot bd, 2 = Tot ang AC, 3 = Tot ang apex, 4 = Tot dih 14, 5 Tot dih 23, 6 Tot imp ab, 7 = Tot imp cd, 8 = Tot wdv, 9 = Tot BI
1035 fprintf (fp, "{%3i,%3i,%3i,%3i,%3i,%3i,%3i,%3i,%3i,%3i}", j, k, l, m, n, o, p, q, r, s);
1036}
1037
1045void print_atom_table (int fid)
1046{
1047 int i, j;
1048 gchar * nodes[4]={"label", "mass", "key", "info"};
1049 fprintf (fp, " <atoms>\n");
1050 for (i=0; i<field_objects[0]; i++)
1051 {
1052 fprintf (fp, " <at");
1053 for (j=0; j<4; j++)
1054 {
1055 fprintf (fp, " %s=\"%s\"", nodes[j], field_atoms[i][j]);
1056 }
1057 fprintf (fp, "/>\n");
1058 }
1059 fprintf (fp, " </atoms>\n");
1060}
1061
1062typedef struct f_bond f_bond;
1064{
1065 int a;
1066 int b;
1067 float v[2];
1070};
1071
1074
1084gboolean not_done (int eid, int a, int b)
1085{
1086 tmpbd = the_bonds[eid];
1087 while (tmpbd)
1088 {
1089 if (tmpbd -> a == a && tmpbd -> b == b) return FALSE;
1090 if (tmpbd -> a == b && tmpbd -> b == a) return FALSE;
1091 tmpbd = tmpbd -> next;
1092 }
1093 return TRUE;
1094}
1095
1109void print_this_bond (int eid, int h, int fid, int inum, char * at_a, char * at_b, char ** the_bond)
1110{
1111 int j;
1112 gchar * node[3] = {"bd-h", "bd-q", "bd-m"};
1113 gchar * aaa = g_strdup_printf ("%s", find_atom_key(fid, 2, at_a));
1114 gchar * bbb = g_strdup_printf ("%s", find_atom_key(fid, 2, at_b));
1115 if (eid < 0 || not_done (eid, find_atom_id (1, aaa), find_atom_id (1, bbb)))
1116 {
1117 if (eid > -1)
1118 {
1119 if (the_bonds[eid])
1120 {
1121 tmpbd = the_bonds[eid];
1122 while (tmpbd -> next) tmpbd = tmpbd -> next;
1123 tmpbd -> next = g_malloc0(sizeof*tmpbd -> next);
1124 tmpbd -> next -> prev = tmpbd;
1125 tmpbd = tmpbd -> next;
1126 }
1127 else
1128 {
1129 the_bonds[eid] = g_malloc0(sizeof*the_bonds[eid]);
1130 tmpbd = the_bonds[eid];
1131 }
1132 tmpbd -> a = find_atom_id (0, aaa);
1133 tmpbd -> b = find_atom_id (0, bbb);
1134 tmpbd -> v[0] = string_to_double ((gpointer)the_bond[2]);
1135 tmpbd -> v[1] = string_to_double ((gpointer)the_bond[3]);
1136 }
1137 fprintf (fp, " <%s a=\"%d\" b=\"%d\" z_a=\"%d\" z_b=\"%d\"",
1138 node[h], find_atom_id (0, aaa), find_atom_id (0, bbb),
1139 find_atom_z (aaa), find_atom_z (bbb));
1140 switch (h)
1141 {
1142 case 0:
1143 if (fid == CVFF || fid == CVFF_AUG || fid == CFF91 || fid == PCFF)
1144 {
1145 fprintf (fp, " K=\"%f\" R_zero=\"%f\"", string_to_double ((gpointer)the_bond[3]), string_to_double ((gpointer)the_bond[2]));
1146 }
1147 else
1148 {
1149 fprintf (fp, " K=\"%f\" R_zero=\"%f\"", string_to_double ((gpointer)the_bond[2]), string_to_double ((gpointer)the_bond[3]));
1150 }
1151 j = 4;
1152 break;
1153 case 1:
1154 fprintf (fp, " K=\"%f\" R_zero=\"%f\" KK=\"%f\" KKK=\"%f\"", string_to_double ((gpointer)the_bond[3]), string_to_double ((gpointer)the_bond[2]), string_to_double ((gpointer)the_bond[4]), string_to_double ((gpointer)the_bond[5]));
1155 j = 6;
1156 break;
1157 case 2:
1158 fprintf (fp, " D=\"%f\" R_zero=\"%f\" Alpha=\"%f\"", string_to_double ((gpointer)the_bond[3]), string_to_double ((gpointer)the_bond[2]), string_to_double ((gpointer)the_bond[4]));
1159 j = 5;
1160 break;
1161 }
1162 if (field_dim[inum+h] > j)
1163 {
1164 fprintf (fp, " info=\"%s\"", the_bond[j]);
1165 }
1166 fprintf (fp, "/>\n");
1167 }
1168 else if (eid > -1)
1169 {
1170 g_debug ("Done:: tmpbd -> a= %d, tmpbd -> b= %d, tmpbd -> v[0]= %f, tmpbd -> v[1]= %f, this.v[0]= %f, this.v[1]=%f",
1171 tmpbd -> a, tmpbd -> b, tmpbd -> v[0], tmpbd -> v[1], string_to_double ((gpointer)the_bond[2]), string_to_double ((gpointer)the_bond[3]));
1172 }
1173 g_free (aaa);
1174 g_free (bbb);
1175}
1176
1185void print_bond_table (int fid, int inum)
1186{
1187 int h, i;//, j, k, l, m;
1188 gchar * bode[3] = {"bonds-h", "bonds-q", "bonds-m"};
1189 gchar * desc[3] = {"Quadratic bonds:\n\n V(R) = K x (R - R0)^2\n"
1190 " With:\n - K = spring constant (kcal mol^-1 A^-2)\n - R = bond distance (A)\n - R0 = equilibrium distance (A)\n",
1191 "Quartic bonds:\n\n V(R) = K x (R - R0)^2 + K' x (R - R0)^3 + K'' x (R - R0)^4\n"
1192 " With:\n - K, K' and K'' = nth order spring constants (kcal mol^-1 A^-2)\n"
1193 " - R = bond distance (A)\n - R0 = equilibrium distance (A)",
1194 "Morse bonds:\n\n V(R) = D x (1 - exp(-ALPHA x (R - R0)))^2\n"
1195 " With:\n - D = well depth\n - ALPHA = well width\n - R = bond distance\n - R0 = equilibrium distance (A)"};
1196 for (h=0; h<3; h++)
1197 {
1198 the_bonds[0] = the_bonds[1] = NULL;
1199 if (field_objects[inum+h])
1200 {
1201 fprintf (fp, " <%s>\n", bode[h]);
1202 fprintf (fp, " <!-- %s -->\n", desc[h]);
1203 /*if (fid > CHARMMSI && fid < OPLSAAP)
1204 {
1205 for (i=0; i<field_objects[inum+h]; i++)
1206 {
1207 if (find_atom_id (1, field_bonds[h][i][0]) == -10 && find_atom_id (1, field_bonds[h][i][1]) == -10)
1208 {
1209 for (j=1; j<3; j++)
1210 {
1211 for (k=0; k<field_objects[j]; k++)
1212 {
1213 if (g_strcmp0 (field_equi[j-1][k][4-j], field_bonds[h][i][0]) == 0)
1214 {
1215 l = (g_strcmp0 (field_bonds[h][i][0], field_bonds[h][i][1]) == 0) ? k : 0;
1216 for (m=l; m<field_objects[j]; m++)
1217 {
1218 if (g_strcmp0 (field_equi[j-1][m][4-j], field_bonds[h][i][1]) == 0)
1219 {
1220 print_this_bond (j-1, h, fid, inum, field_equi[j-1][k][0], field_equi[j-1][m][0], field_bonds[h][i]);
1221 }
1222 }
1223 }
1224 }
1225 }
1226 }
1227 else if (find_atom_id (1, field_bonds[h][i][0]) == -10)
1228 {
1229 for (j=1; j<3; j++)
1230 {
1231 for (k=0; k<field_objects[j]; k++)
1232 {
1233 if (g_strcmp0 (field_equi[j-1][k][4-j], field_bonds[h][i][0]) == 0)
1234 {
1235 print_this_bond (j-1, h, fid, inum, field_equi[j-1][k][0], field_bonds[h][i][1], field_bonds[h][i]);
1236 }
1237 }
1238 }
1239 }
1240 else if (find_atom_id (1, field_bonds[h][i][1]) == -10)
1241 {
1242 for (j=1; j<3; j++)
1243 {
1244 for (k=0; k<field_objects[j]; k++)
1245 {
1246 if (g_strcmp0 (field_equi[j-1][k][4-j], field_bonds[h][i][1]) == 0)
1247 {
1248 print_this_bond (j-1, h, fid, inum, field_bonds[h][i][0], field_equi[j-1][k][0], field_bonds[h][i]);
1249 }
1250 }
1251 }
1252 }
1253 else
1254 {
1255 print_this_bond (-1, h, fid, inum, field_bonds[h][i][0], field_bonds[h][i][1], field_bonds[h][i]);
1256 }
1257 for (j=0; j<2; j++)
1258 {
1259 if (the_bonds[j])
1260 {
1261 tmpbd = the_bonds[j];
1262 while (tmpbd -> next)
1263 {
1264 tmpbd = tmpbd -> next;
1265 g_free (tmpbd -> prev);
1266 }
1267 g_free (tmpbd);
1268 the_bonds[j] = NULL;
1269 }
1270 }
1271 }
1272 fprintf (fp, " </%s>\n", bode[h]);
1273 }
1274 else*/
1275 {
1276 for (i=0; i<field_objects[inum+h]; i++)
1277 {
1278 print_this_bond (-1, h, fid, inum, field_bonds[h][i][0], field_bonds[h][i][1], field_bonds[h][i]);
1279 }
1280 fprintf (fp, " </%s>\n", bode[h]);
1281 }
1282 }
1283 /*if (the_bonds[0] || the_bonds[1])
1284 {
1285 for (i=0; i<2; i++)
1286 {
1287 if (the_bonds[i])
1288 {
1289 tmpbd = the_bonds[i];
1290 while (tmpbd -> next)
1291 {
1292 tmpbd = tmpbd -> next;
1293 g_free (tmpbd -> prev);
1294 }
1295 g_free (tmpbd);
1296 }
1297 }
1298 }*/
1299 }
1300}
1301
1302typedef struct f_angl f_angl;
1304{
1305 int a;
1306 int b;
1307 int c;
1308 float v[2];
1311};
1312
1315
1326gboolean not_done_an (int eid, int a, int b, int c)
1327{
1328 tmpan = the_angles[eid];
1329 while (tmpan)
1330 {
1331 if (tmpan -> a == a && tmpan -> b == b && tmpan -> c == c) return FALSE;
1332 if (tmpan -> a == c && tmpan -> b == b && tmpan -> c == a) return FALSE;
1333 tmpan = tmpan -> next;
1334 }
1335 return TRUE;
1336}
1337
1353void print_this_angle (int eid, int h, int fid, int inum, int ub, char * at_a, char * at_b, char * at_c, char ** the_angle)
1354{
1355 int j;
1356 gchar * node[2] = {"ang-h", "ang-q"};
1357 gchar * aaa = g_strdup_printf ("%s", find_atom_key(fid, 3, at_a));
1358 gchar * bbb = g_strdup_printf ("%s", find_atom_key(fid, 3, at_b));
1359 gchar * ccc = g_strdup_printf ("%s", find_atom_key(fid, 3, at_c));
1360 if (eid < 0 || not_done_an (eid, find_atom_id (1, aaa), find_atom_id (1, bbb), find_atom_id (1, ccc)))
1361 {
1362 if (eid > -1)
1363 {
1364 if (the_angles[eid])
1365 {
1366 tmpan = the_angles[eid];
1367 while (tmpan -> next) tmpan = tmpan -> next;
1368 tmpan -> next = g_malloc0(sizeof*tmpan -> next);
1369 tmpan -> next -> prev = tmpan;
1370 tmpan = tmpan -> next;
1371 }
1372 else
1373 {
1374 the_angles[eid] = g_malloc0(sizeof*the_angles[eid]);
1375 tmpan = the_angles[eid];
1376 }
1377 tmpan -> a = find_atom_id (0, aaa);
1378 tmpan -> b = find_atom_id (0, bbb);
1379 tmpan -> c = find_atom_id (0, ccc);
1380 tmpan -> v[0] = string_to_double ((gpointer)the_angle[3]);
1381 tmpan -> v[1] = string_to_double ((gpointer)the_angle[4]);
1382 }
1383 fprintf (fp, " <%s a=\"%d\" b=\"%d\" c=\"%d\" z_a=\"%d\" z_b=\"%d\" z_c=\"%d\"",
1384 node[h], find_atom_id (0, aaa), find_atom_id (0, bbb), find_atom_id (0, ccc),
1385 find_atom_z (aaa), find_atom_z (bbb), find_atom_z (ccc));
1386 switch (h)
1387 {
1388 case 0:
1389 if (fid >= CVFF && fid < COMPASS)
1390 {
1391 fprintf (fp, " K=\"%f\" Theta_zero=\"%f\"", string_to_double ((gpointer)the_angle[4]), string_to_double ((gpointer)the_angle[3]));
1392 }
1393 else
1394 {
1395 fprintf (fp, " K=\"%f\" Theta_zero=\"%f\"", string_to_double ((gpointer)the_angle[3]), string_to_double ((gpointer)the_angle[4]));
1396 }
1397 if (ub)
1398 {
1399 fprintf (fp, " Kub=\"%f\" S_zero=\"%f\"", string_to_double ((gpointer)the_angle[5]), string_to_double ((gpointer)the_angle[6]));
1400 }
1401 j = (ub) ? 7 : 5;
1402 break;
1403 case 1:
1404 fprintf (fp, " K=\"%f\" Theta_zero=\"%f\" KK=\"%f\" KKK=\"%f\"", string_to_double ((gpointer)the_angle[4]), string_to_double ((gpointer)the_angle[3]),
1405 string_to_double ((gpointer)the_angle[5]), string_to_double ((gpointer)the_angle[6]));
1406 j = 7;
1407 break;
1408 }
1409 if (field_dim[inum+h] > j)
1410 {
1411 fprintf (fp, " info=\"%s\"", the_angle[j]);
1412 }
1413 fprintf (fp, "/>\n");
1414 }
1415 else if (eid > -1)
1416 {
1417 g_debug ("Done:: tmpan -> a= %d, tmpan -> b= %d, tmpan -> c= %d, tmpan -> v[0]= %f, tmpan -> v[1]= %f, this.v[0]= %f, this.v[1]=%f",
1418 tmpan -> a, tmpan -> b, tmpan -> c, tmpan -> v[0], tmpan -> v[1], string_to_double ((gpointer)the_angle[3]), string_to_double ((gpointer)the_angle[4]));
1419 }
1420 g_free (aaa);
1421 g_free (bbb);
1422 g_free (ccc);
1423}
1424
1433void print_angle_table (int fid, int inum)
1434{
1435 int h, i;//, j, k, l;
1436 int ub = (fid > AMBER99 && fid <= CHARMMSI) ? 2 : 0; // Urey-Bradley parameter for the CHARMM FF
1437 gchar * aode[2] = {"angles-h", "angles-q"};
1438
1439 gchar * desc[3] = {"Quadratic angles:\n\n V(Theta) = K x (Theta - Theta0)^2\n"
1440 " With:\n - K = spring constant (kcal mol^-1 rad^-2)\n - Theta = angle (°)\n - Theta0 = equilibrium angle (°)",
1441 "Quartic angles:\n\n V(Theta) = K x (Theta - Theta0)^2 + K' x (Theta - Theta0)^3 + K' x (Theta - Theta0)^4\n"
1442 " With:\n - K, K' and K'' = nth order spring constant (kcal mol^-1 rad^-nth)\n - Theta = angle (°)\n - Theta0 = equilibrium angle (°)",
1443 "Quadratic angles + Urey-Bradley (UB) parameters:\n\n V(Theta) = K x (Theta - Theta0)^2\n"
1444 " With:\n - K = spring constant (kcal mol^-1 rad^-2)\n - Theta = angle (°)\n - Theta0 = equilibrium angle(°)\n"
1445 " V(S) = Kub x (R - Rub)^2\n"
1446 " With:\n - Kub = spring constant (kcal mol^-1 A^-2)\n - S = distance 1-3 (A)\n - S0 = equilibrium distance 1-3 (A)"};
1447 for (h=0; h<2; h++)
1448 {
1449 the_angles[0] = the_angles[1] = NULL;
1450 if (field_objects[inum+h])
1451 {
1452 fprintf (fp, " <%s>\n", aode[h]);
1453 fprintf (fp, " <!-- %s -->\n", desc[h+ub]);
1454 /*if (fid > CHARMMSI && fid < OPLSAAP)
1455 {
1456 for (i=0; i<field_objects[inum+h]; i++)
1457 {
1458 if (find_atom_id (1, field_angles[h][i][0]) == -10 && find_atom_id (1, field_angles[h][i][1]) == -10 && find_atom_id (1, field_angles[h][i][2]) == -10)
1459 {
1460 for (j=0; j<field_objects[2]; j++)
1461 {
1462 if (g_strcmp0 (field_equi[1][j][3], field_angles[h][i][0]) == 0)
1463 {
1464 for (k=0; k<field_objects[2]; k++)
1465 {
1466 if (g_strcmp0 (field_equi[1][k][3], field_angles[h][i][1]) == 0)
1467 {
1468 for (l=0; l<field_objects[2]; l++)
1469 {
1470 if (g_strcmp0 (field_equi[1][l][3], field_angles[h][i][2]) == 0)
1471 {
1472 print_this_angle (1, h, fid, inum, ub, field_equi[1][j][0], field_equi[1][k][0], field_equi[1][l][0], field_angles[h][i]);
1473 }
1474 }
1475 }
1476 }
1477 }
1478 }
1479 for (j=0; j<field_objects[1]; j++)
1480 {
1481 if (g_strcmp0 (field_equi[0][j][4], field_angles[h][i][0]) == 0)
1482 {
1483 for (k=0; k<field_objects[1]; k++)
1484 {
1485 if (g_strcmp0 (field_equi[0][k][5], field_angles[h][i][1]) == 0)
1486 {
1487 for (l=0; l<field_objects[1]; l++)
1488 {
1489 if (g_strcmp0 (field_equi[0][l][4], field_angles[h][i][2]) == 0)
1490 {
1491 print_this_angle (0, h, fid, inum, ub, field_equi[0][j][0], field_equi[0][k][0], field_equi[0][l][0], field_angles[h][i]);
1492 }
1493 }
1494 }
1495 }
1496 }
1497 }
1498 }
1499 else if (find_atom_id (1, field_angles[h][i][0]) == -10 && find_atom_id (1, field_angles[h][i][1]) == -10)
1500 {
1501 for (j=0; j<field_objects[2]; j++)
1502 {
1503 if (g_strcmp0 (field_equi[1][j][3], field_angles[h][i][0]) == 0)
1504 {
1505 for (k=0; k<field_objects[2]; k++)
1506 {
1507 if (g_strcmp0 (field_equi[1][k][3], field_angles[h][i][1]) == 0)
1508 {
1509 print_this_angle (1, h, fid, inum, ub, field_equi[1][j][0], field_equi[1][k][0], field_angles[h][i][2], field_angles[h][i]);
1510 }
1511 }
1512 }
1513 }
1514 // End - Appex
1515 for (j=0; j<field_objects[1]; j++)
1516 {
1517 if (g_strcmp0 (field_equi[0][j][4], field_angles[h][i][0]) == 0)
1518 {
1519 for (k=0; k<field_objects[1]; k++)
1520 {
1521 if (g_strcmp0 (field_equi[0][k][5], field_angles[h][i][1]) == 0)
1522 {
1523 print_this_angle (0, h, fid, inum, ub, field_equi[0][j][0], field_equi[0][k][0], field_angles[h][i][2], field_angles[h][i]);
1524 }
1525 }
1526 }
1527 }
1528 }
1529 else if (find_atom_id (1, field_angles[h][i][0]) == -10 && find_atom_id (1, field_angles[h][i][2]) == -10)
1530 {
1531 for (j=0; j<field_objects[2]; j++)
1532 {
1533 if (g_strcmp0 (field_equi[1][j][3], field_angles[h][i][0]) == 0)
1534 {
1535 for (k=0; k<field_objects[2]; k++)
1536 {
1537 if (g_strcmp0 (field_equi[1][k][3], field_angles[h][i][2]) == 0)
1538 {
1539 print_this_angle (1, h, fid, inum, ub, field_equi[1][j][0], field_angles[h][i][1], field_equi[1][k][0], field_angles[h][i]);
1540 }
1541 }
1542 }
1543 }
1544 // End - End
1545 for (j=0; j<field_objects[1]; j++)
1546 {
1547 if (g_strcmp0 (field_equi[0][j][4], field_angles[h][i][0]) == 0)
1548 {
1549 for (k=0; k<field_objects[1]; k++)
1550 {
1551 if (g_strcmp0 (field_equi[0][k][4], field_angles[h][i][2]) == 0)
1552 {
1553 print_this_angle (0, h, fid, inum, ub, field_equi[0][j][0], field_angles[h][i][1], field_equi[0][k][0], field_angles[h][i]);
1554 }
1555 }
1556 }
1557 }
1558 }
1559 else if (find_atom_id (1, field_angles[h][i][1]) == -10 && find_atom_id (1, field_angles[h][i][2]) == -10)
1560 {
1561 for (j=0; j<field_objects[2]; j++)
1562 {
1563 if (g_strcmp0 (field_equi[1][j][3], field_angles[h][i][1]) == 0)
1564 {
1565 for (k=0; k<field_objects[2]; k++)
1566 {
1567 if (g_strcmp0 (field_equi[1][k][3], field_angles[h][i][2]) == 0)
1568 {
1569 print_this_angle (1, h, fid, inum, ub, field_angles[h][i][0], field_equi[1][j][0], field_equi[1][k][0], field_angles[h][i]);
1570 }
1571 }
1572 }
1573 }
1574 // Appex - End
1575 for (j=0; j<field_objects[1]; j++)
1576 {
1577 if (g_strcmp0 (field_equi[0][j][5], field_angles[h][i][1]) == 0)
1578 {
1579 for (k=0; k<field_objects[1]; k++)
1580 {
1581 if (g_strcmp0 (field_equi[0][k][4], field_angles[h][i][2]) == 0)
1582 {
1583 print_this_angle (0, h, fid, inum, ub, field_angles[h][i][0], field_equi[0][j][0], field_equi[0][k][0], field_angles[h][i]);
1584 }
1585 }
1586 }
1587 }
1588 }
1589 else if (find_atom_id (1, field_angles[h][i][0]) == -10)
1590 {
1591 for (j=0; j<field_objects[2]; j++)
1592 {
1593 if (g_strcmp0 (field_equi[1][j][3], field_angles[h][i][0]) == 0)
1594 {
1595 print_this_angle (1, h, fid, inum, ub, field_equi[1][j][0], field_angles[h][i][1], field_angles[h][i][2], field_angles[h][i]);
1596 }
1597 }
1598 // End
1599 for (j=0; j<field_objects[1]; j++)
1600 {
1601 if (g_strcmp0 (field_equi[0][j][4], field_angles[h][i][0]) == 0)
1602 {
1603 print_this_angle (0, h, fid, inum, ub, field_equi[0][j][0], field_angles[h][i][1], field_angles[h][i][2], field_angles[h][i]);
1604 }
1605 }
1606 }
1607 else if (find_atom_id (1, field_angles[h][i][1]) == -10)
1608 {
1609 for (j=0; j<field_objects[2]; j++)
1610 {
1611 if (g_strcmp0 (field_equi[1][j][3], field_angles[h][i][1]) == 0)
1612 {
1613 print_this_angle (1, h, fid, inum, ub, field_angles[h][i][0], field_equi[1][j][0], field_angles[h][i][2], field_angles[h][i]);
1614 }
1615 }
1616 // Appex
1617 for (j=0; j<field_objects[1]; j++)
1618 {
1619 if (g_strcmp0 (field_equi[0][j][5], field_angles[h][i][1]) == 0)
1620 {
1621 print_this_angle (0, h, fid, inum, ub, field_angles[h][i][0], field_equi[0][j][0], field_angles[h][i][2], field_angles[h][i]);
1622 }
1623 }
1624 }
1625 else if (find_atom_id (1, field_angles[h][i][2]) == -10)
1626 {
1627 for (j=0; j<field_objects[2]; j++)
1628 {
1629 if (g_strcmp0 (field_equi[1][j][3], field_angles[h][i][2]) == 0)
1630 {
1631 print_this_angle (1, h, fid, inum, ub, field_angles[h][i][0], field_angles[h][i][1], field_equi[1][j][0], field_angles[h][i]);
1632 }
1633 }
1634 // End
1635 for (j=0; j<field_objects[1]; j++)
1636 {
1637 if (g_strcmp0 (field_equi[0][j][4], field_angles[h][i][2]) == 0)
1638 {
1639 print_this_angle (0, h, fid, inum, ub, field_angles[h][i][0], field_angles[h][i][1], field_equi[0][j][0], field_angles[h][i]);
1640 }
1641 }
1642 }
1643 else
1644 {
1645 print_this_angle (-1, h, fid, inum, ub, field_angles[h][i][0], field_angles[h][i][1], field_angles[h][i][2], field_angles[h][i]);
1646 }
1647 for (j=0; j<2; j++)
1648 {
1649 if (the_angles[j])
1650 {
1651 tmpan = the_angles[j];
1652 while (tmpan -> next)
1653 {
1654 tmpan = tmpan -> next;
1655 g_free (tmpan -> prev);
1656 }
1657 g_free (tmpan);
1658 the_angles[j] = NULL;
1659 }
1660 }
1661 }
1662 }
1663 else*/
1664 {
1665 for (i=0; i<field_objects[inum+h]; i++)
1666 {
1667 print_this_angle (-1, h, fid, inum, ub, field_angles[h][i][0], field_angles[h][i][1], field_angles[h][i][2], field_angles[h][i]);
1668 }
1669 }
1670 fprintf (fp, " </%s>\n", aode[h]);
1671 }
1672 }
1673}
1674
1683void print_dihedral_table (int fid, int inum)
1684{
1685 int h, i, j;
1686 gchar * dode[2] = {"dihedrals-c", "dihedrals-ccc"};
1687 gchar * node[2] = {"dih-c", "dih-ccc"};
1688 gchar * desc[2] = {"Dihedrals / torsions:\n\n V(Phi) = K x (1 + cos(n x Phi - Phi0))\n"
1689 " With:\n - K = spring constant (kcal mol^-1 rad^-2)\n - Phi = dihedral angle (°)\n - n = multiplicity\n - Phi0 = phase shift angle (°)",
1690 "Dihedrals / torsions\n\n V(Phi) = K x (Phi - Phi0)^2 + K' x (Phi - Phi0)^3 + K'' x (Phi - Phi0)^4\n"
1691 " With:\n - K, K' and K'' = nth order spring constant (kcal mol^-1 rad^-nth)\n - Phi = dihedral angle (°)\n - Phi0 = phase shift angle (°)"};
1692 for (h=0; h<2; h++)
1693 {
1694 if (field_objects[inum+h])
1695 {
1696 fprintf (fp, " <%s>\n", dode[h]);
1697 fprintf (fp, " <!-- %s -->\n", desc[h]);
1698 for (i=0; i<field_objects[inum+h]; i++)
1699 {
1700 gchar * aaa = g_strdup_printf ("%s", find_atom_key(fid, 4, field_dihedrals[h][i][0]));
1701 gchar * bbb = g_strdup_printf ("%s", find_atom_key(fid, 4, field_dihedrals[h][i][1]));
1702 gchar * ccc = g_strdup_printf ("%s", find_atom_key(fid, 4, field_dihedrals[h][i][2]));
1703 gchar * ddd = g_strdup_printf ("%s", find_atom_key(fid, 4, field_dihedrals[h][i][3]));
1704 fprintf (fp, " <%s a=\"%d\" b=\"%d\" c=\"%d\" d=\"%d\" z_a=\"%d\" z_b=\"%d\" z_c=\"%d\" z_d=\"%d\"",
1705 node[h], find_atom_id (1, aaa), find_atom_id (1, bbb), find_atom_id (1, ccc), find_atom_id (1, ddd),
1706 find_atom_z (aaa), find_atom_z (bbb), find_atom_z (ccc), find_atom_z (ddd));
1707 g_free (aaa);
1708 g_free (bbb);
1709 g_free (ccc);
1710 g_free (ddd);
1711 switch (h)
1712 {
1713 case 0:
1714 if (fid < 4)
1715 {
1716 fprintf (fp, " K=\"%f\" Phi_zero=\"%f\" n=\"%f\"", string_to_double ((gpointer)field_dihedrals[h][i][5]) / string_to_double ((gpointer)field_dihedrals[h][i][4]),
1717 string_to_double ((gpointer)field_dihedrals[h][i][6]), string_to_double ((gpointer)field_dihedrals[h][i][7]));
1718 j = 8;
1719 }
1720 else
1721 {
1722 fprintf (fp, " K=\"%f\" Phi_zero=\"%f\" n=\"%f\"", string_to_double ((gpointer)field_dihedrals[h][i][4]), string_to_double ((gpointer)field_dihedrals[h][i][6]),
1723 string_to_double ((gpointer)field_dihedrals[h][i][5]));
1724 j = 7;
1725 }
1726 break;
1727 case 1:
1728 fprintf (fp, " K=\"%f\" Phi_zero=\"%f\" KK=\"%f\" KKK=\"%f\"", string_to_double ((gpointer)field_dihedrals[h][i][4]), string_to_double ((gpointer)field_dihedrals[h][i][5]),
1729 string_to_double ((gpointer)field_dihedrals[h][i][6]), string_to_double ((gpointer)field_dihedrals[h][i][8]));
1730 j = 10;
1731 break;
1732 }
1733 if (field_dim[inum+h] > j)
1734 {
1735 fprintf (fp, " info=\"%s\"", field_dihedrals[h][i][j]);
1736 }
1737 fprintf (fp, "/>\n");
1738 }
1739 fprintf (fp, " </%s>\n", dode[h]);
1740 }
1741 }
1742}
1743
1752void print_improper_table (int fid, int inum)
1753{
1754 int i, j;
1755 gchar * desc[2] = {"Impropers:\n\n V(Phi) = K x (1 + cos(n x Phi - Phi0))\n"
1756 " With:\n - K = spring constant (kcal mol^-1 rad^-2)\n - Phi = angle (°)\n - n = multiplicity\n - Phi0 = equilibrium angle (°)",
1757 "Impropers: V(Phi) = K x (Phi - Phi0)^2\n\n"
1758 " With:\n - K = spring constant (kcal mol^-1 rad^-2)\n - Phi = angle (°)\n - Phi0 = equilibrium angle (°)"};
1759 int wid = (fid < 4 || fid == OPLSAAP || fid == OPLSAAR) ? 3 : 2;
1760 if (field_objects[inum])
1761 {
1762 fprintf (fp, " <impropers>\n");
1763 fprintf (fp, " <!-- %s -->\n", desc[wid == 3 ? 0 : 1]);
1764 for (i=0; i<field_objects[inum]; i++)
1765 {
1766 gchar * aaa = g_strdup_printf ("%s", find_atom_key(fid, 5, (fid > AMBER99 && fid < CVFF) ? field_impropers[i][0]: field_impropers[i][1]));
1767 gchar * bbb = g_strdup_printf ("%s", find_atom_key(fid, 5, (fid > AMBER99 && fid < CVFF) ? field_impropers[i][1]: field_impropers[i][0]));
1768 gchar * ccc = g_strdup_printf ("%s", find_atom_key(fid, 5, field_impropers[i][2]));
1769 gchar * ddd = g_strdup_printf ("%s", find_atom_key(fid, 5, field_impropers[i][3]));
1770 fprintf (fp, " <imp a=\"%d\" b=\"%d\" c=\"%d\" d=\"%d\" z_a=\"%d\" z_b=\"%d\" z_c=\"%d\" z_d=\"%d\"",
1771 find_atom_id (1, aaa), find_atom_id (1, bbb), find_atom_id (1, ccc), find_atom_id (1, ddd),
1772 find_atom_z (aaa), find_atom_z (bbb), find_atom_z (ccc), find_atom_z (ddd));
1773 g_free (aaa);
1774 g_free (bbb);
1775 g_free (ccc);
1776 g_free (ddd);
1777 if (fid < 4)
1778 {
1779 fprintf (fp, " K=\"%f\" Phi_zero=\"%f\" n=\"%f\"", string_to_double ((gpointer)field_impropers[i][4]), string_to_double ((gpointer)field_impropers[i][5]), string_to_double ((gpointer)field_impropers[i][6]));
1780 j = 7;
1781 }
1782 else if (wid == 3)
1783 {
1784 fprintf (fp," K=\"%f\" Phi_zero=\"%f\" n=\"%f\"", string_to_double ((gpointer)field_impropers[i][4]), string_to_double ((gpointer)field_impropers[i][6]), string_to_double ((gpointer)field_impropers[i][5]));
1785 j = 7;
1786 }
1787 else if (fid > AMBER99 && fid < CVFF)
1788 {
1789 fprintf (fp, " K=\"%f\" Phi_zero=\"%f\"", string_to_double ((gpointer)field_impropers[i][4]), string_to_double ((gpointer)field_impropers[i][6]));
1790 j = 7;
1791 }
1792 else
1793 {
1794 fprintf (fp, " K=\"%f\" Phi_zero=\"%f\"", string_to_double ((gpointer)field_impropers[i][4]), string_to_double ((gpointer)field_impropers[i][5]));
1795 j = 6;
1796 }
1797 if (field_dim[inum] > j)
1798 {
1799 fprintf (fp, " info=\"%s\"", field_impropers[i][j]);
1800 }
1801 fprintf (fp, "/>\n");
1802 }
1803 fprintf (fp, " </impropers>\n");
1804 }
1805}
1806
1815void print_inversion_table (int fid, int inum)
1816{
1817 int i;
1818 gchar * desc = {"Inversions\n 0= Key_a, 1= Key_b, 2= Key_c, 3= Key_d, 4= K, 5= Phi0, 7= FF info\n\n V(φ) = K x (Phi - Phi0)^2\n"
1819 " With:\n - K = spring constant (kcal mol^-1 rad^-2)\n - Phi = angle (°)\n - Phi0 = equilibrium angle (°)"};
1820 if (field_objects[inum])
1821 {
1822 fprintf (fp, " <inversions>\n");
1823 fprintf (fp, " <!-- %s -->\n", desc);
1824 for (i=0; i<field_objects[inum]; i++)
1825 {
1826 gchar * aaa = g_strdup_printf ("%s", find_atom_key(fid, 5, field_inversions[i][1]));
1827 gchar * bbb = g_strdup_printf ("%s", find_atom_key(fid, 5, field_inversions[i][0]));
1828 gchar * ccc = g_strdup_printf ("%s", find_atom_key(fid, 5, field_inversions[i][2]));
1829 gchar * ddd = g_strdup_printf ("%s", find_atom_key(fid, 5, field_inversions[i][3]));
1830 fprintf (fp, " <inv a=\"%d\" b=\"%d\" c=\"%d\" d=\"%d\" z_a=\"%d\" z_b=\"%d\" z_c=\"%d\" z_d=\"%d\" K=\"%f\" Phi_zero=\"%f\"",
1831 find_atom_id (1, aaa), find_atom_id (1, bbb), find_atom_id (1, ccc), find_atom_id (1, ddd),
1832 find_atom_z (aaa), find_atom_z (bbb), find_atom_z (ccc), find_atom_z (ddd),
1833 string_to_double ((gpointer)field_inversions[i][4]), string_to_double ((gpointer)field_inversions[i][5]));
1834 g_free (aaa);
1835 g_free (bbb);
1836 g_free (ccc);
1837 g_free (ddd);
1838 if (field_dim[inum] > 6)
1839 {
1840 fprintf (fp, " info=\"%s\"", field_inversions[i][6]);
1841 }
1842 fprintf (fp, "/>\n");
1843 }
1844 fprintf (fp, " </inversions>\n");
1845 }
1846}
1847
1856void print_vdw_table (int fid, int inum)
1857{
1858 int i, j, k, l;
1859 gchar * desc[3] = {"Non-bonded 12-6\n 0= Key_a, 1= Epslion, 2= R0 (A), 3= FF info\n\n Non-bonded (12-6): V(rij) = Epslion(ij) x [(R0(ij)/rij)^12 - 2 x (R0(ij)/rij)^6]\n"
1860 " With:\n"
1861 " Epslion(ij) = sqrt(Epslion(i) x Epslion(j)) and Epslion(i) (kcal mol^-1)\n"
1862 " R0(ij)= (R0(i) + R0(j))/2 and R0(i) (A)\n",
1863 "Non-bonded 12-6\n 0= Key_a, 1= A, 2= B, 3= FF info\n\n Non-bonded (12-6): V(rij) = A(ij)/rij^12 - B(ij)/rij^6\n"
1864 " With:\n"
1865 " A(ij) = sqrt(Ai x Aj)\n"
1866 " B(ij) = sqrt(Bi x Bj)\n",
1867 "Non-bonded 9-6\n 0= Key_a, 1= Epslion, 2= R0 (A), 3= FF info\n\n Non-bonded (9-6): V(rij) = Epslion(ij) x [2 x (R0(ij)/rij)^9 - 3 x (R0(ij)/rij)^6]\n"
1868 " With:\n"
1869 " Epslion(ij) = 2 x sqrt(Epslion(i) x Epslion(j)) x R0(i)^3 x R0(j)^3 / [ R0(i)^6 + R0(j)^6 ] and Epslion(i) (kcal mol^-1)\n"
1870 " R0(ij)= ((R0(i)^6 + R0(j)^6)/2) ^ 1/6 and R0(i) (A)\n"};
1871
1872 int wid = ((fid >= CHARMM22P && fid <= CHARMMSI) || (fid >= OPLSAAP)) ? 1 : 0;
1873 int did = (fid <= CHARMMSI || fid >= OPLSAAP) ? 0 : (fid == CVFF || fid == CVFF_AUG) ? 1 : 2;
1874 int cid = (fid > COMPASS) ? 1 : 0;
1875 int wdi[2] = {2, 4};
1876 if (field_objects[inum])
1877 {
1878 fprintf (fp, " <non-bonded>\n");
1879 fprintf (fp, " <!-- %s -->\n", desc[did]);
1880 for (i=0; i<field_objects[inum]; i++)
1881 {
1882 gchar * aaa = g_strdup_printf ("%s", find_atom_key(fid, 1, field_vdw[i][0]));
1883 fprintf (fp, " <non-bd a=\"%d\" z_a=\"%d\"", find_atom_id (0, aaa), find_atom_z (aaa));
1884 g_free (aaa);
1885 if (did == 1)
1886 {
1887 fprintf (fp, " A=\"%f\" B= \"%f\"", string_to_double ((gpointer)field_vdw[i][1]), string_to_double ((gpointer)field_vdw[i][2]));
1888 }
1889 else
1890 {
1891 if (fid <= AMBER99)
1892 {
1893 fprintf (fp, " Ei=\"%f\" Ri=\"%f\"", string_to_double ((gpointer)field_vdw[i][2]), string_to_double ((gpointer)field_vdw[i][1]));
1894 }
1895 else
1896 {
1897 fprintf (fp, " Ei=\"%f\" Ri=\"%f\"", string_to_double ((gpointer)field_vdw[i][1+cid]), string_to_double ((gpointer)field_vdw[i][2+cid]));
1898 }
1899 if ((fid >= CHARMM22P && fid <= CHARMMSI) || fid > COMPASS)
1900 {
1901 fprintf (fp, " Eii=\"%f\" Rii=\"%f\"", string_to_double ((gpointer)field_vdw[i][3+2*cid]), string_to_double ((gpointer)field_vdw[i][4+2*cid]));
1902 }
1903 }
1904 j = wdi[wid]+1+2*cid;
1905
1906 if (field_dim[inum] > j)
1907 {
1908 fprintf (fp, " info=\"%s\"", field_vdw[i][j]);
1909 }
1910 fprintf (fp, "/>\n");
1911 if (fid <= AMBER99)
1912 {
1913 for (k=0; k<field_objects[1]; k++)
1914 {
1915 if (g_strcmp0 (field_equi[0][k][0], field_vdw[i][0]) == 0)
1916 {
1917 for (l=1; l<field_dim[1]; l++)
1918 {
1919 if(g_strcmp0 (field_equi[0][k][l], " ") != 0)
1920 {
1921 fprintf (fp, " <non-bd a=\"%d\" z_a=\"%d\"", find_atom_id (0, field_equi[0][k][l]), find_atom_z (field_vdw[i][0]));
1922 fprintf (fp, " Ei=\"%f\" Ri=\"%f\"", string_to_double ((gpointer)field_vdw[i][2]), string_to_double ((gpointer)field_vdw[i][1]));
1923 if (field_dim[inum] > j)
1924 {
1925 fprintf (fp, " info=\"Equi. to %s\"", field_vdw[i][0]);
1926 }
1927 fprintf (fp, "/>\n");
1928 }
1929 }
1930 }
1931 }
1932 }
1933 }
1934 fprintf (fp, " </non-bonded>\n");
1935 }
1936}
1937
1938
1939field_object_match * field_objects_id[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
1941
1942char *** ff_atoms;
1943// 0 = Quadratic, 1 = Quartic, 2 = Morse
1944
1951
1957
1964{
1965 int i, j, k, l;
1966 atoms_id = allocint (tmp_proj -> nspec);
1967 extraz_id = allocdint (5, tmp_proj -> nspec);
1968 atoms_id_list = g_malloc (tmp_proj -> nspec*sizeof*atoms_id_list);
1969 k = 0;
1970 for (i=0; i<tmp_proj -> nspec; i++)
1971 {
1972 atoms_id[i] = 0;
1973#ifdef DEBUG
1974 g_debug ("Searching field atoms for spec: %d, label= %s, z= %d", i, tmp_proj -> chemistry -> label[i], (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][i]);
1975#endif
1976 for (j=0; j<ff_objects[0]; j++)
1977 {
1978 if (g_strcmp0 (exact_name(tmp_proj -> chemistry -> label[i]), exact_name(ff_atoms[j][0])) == 0)
1979 {
1980 atoms_id[i] ++;
1981 }
1982 }
1983 if (atoms_id[i] > 0) k ++;
1984 }
1985 for (i=0; i<tmp_proj -> nspec; i++)
1986 {
1987#ifdef DEBUG
1988 g_debug ("For spec: %d, number of match = %d", i, atoms_id[i]);
1989#endif
1990 if (atoms_id[i])
1991 {
1992 atoms_id_list[i] = g_malloc0 (atoms_id[i]*sizeof*atoms_id_list[i]);
1993 l = 0;
1994 for (j=0; j<ff_objects[0]; j++)
1995 {
1996 if (g_strcmp0 (exact_name(tmp_proj -> chemistry -> label[i]), exact_name(ff_atoms[j][0])) == 0)
1997 {
1998 atoms_id_list[i][l] = j;
1999 l ++;
2000 }
2001 }
2002 }
2003 }
2004 return k;
2005}
2006
2008
2018gboolean is_a_match (int * data, int num, int val[4])
2019{
2020 int i;
2021 for (i=0; i<num; i++)
2022 {
2023 if (data[i] == -1) is_extra = 1;
2024 if (data[i] != val[i] && data[i] != -1) return FALSE;
2025 }
2026 return TRUE;
2027}
2028
2046void find_object_ijkl (int hid, int foid, int oid, int sa, int za, int sb, int zb, int sc, int zc, int sd, int zd)
2047{
2048 int h, i;
2049 int val[4];
2050 val[0] = za;
2051 val[1] = zb;
2052 val[2] = zc;
2053 val[3] = zd;
2054 gboolean do_this_id, save_this_id;
2055 field_object_match * test_obj_id;
2056 for (h=0; h<2+hid; h++)
2057 {
2058 if (ff_objects[h+foid] > 0)
2059 {
2060 for (i=0; i<ff_objects[h+foid]; i++)
2061 {
2062 do_this_id = FALSE;
2063 is_extra = 0;
2064 switch (oid+2)
2065 {
2066 case FBDS:
2067 do_this_id = is_a_match (ff_bonds[h] -> atoms_z[i], 2, val);
2068 break;
2069 case FANG:
2070 do_this_id = is_a_match (ff_angles[h] -> atoms_z[i], 3, val);
2071 break;
2072 case FDIH:
2073 do_this_id = is_a_match (ff_dih[h] -> atoms_z[i], 4, val);
2074 break;
2075 case FIMP:
2076 do_this_id = is_a_match (ff_imp -> atoms_z[i], 4, val);
2077 break;
2078 case FINV:
2079 do_this_id = is_a_match (ff_inv -> atoms_z[i], 4, val);
2080 break;
2081 case FNBD:
2082 do_this_id = is_a_match (ff_vdw -> atoms_z[i], 1, val);
2083 break;
2084 default:
2085 break;
2086 }
2087 if (do_this_id)
2088 {
2089 save_this_id = TRUE;
2090 if (field_objects_id[oid])
2091 {
2092 test_obj_id = field_objects_id[oid];
2093 while (test_obj_id != NULL)
2094 {
2095 if (test_obj_id -> type == h && test_obj_id -> oid == i)
2096 {
2097 save_this_id = FALSE;
2098 break;
2099 }
2100 test_obj_id = test_obj_id -> next;
2101 }
2102 if (save_this_id)
2103 {
2104 tmp_obj_id -> next = g_malloc0 (sizeof*tmp_obj_id -> next);
2105 tmp_obj_id -> next -> id = tmp_obj_id -> id + 1;
2106 tmp_obj_id = tmp_obj_id -> next;
2107 }
2108 }
2109 else
2110 {
2111 field_objects_id[oid] = g_malloc0 (sizeof*field_objects_id[oid]);
2113 }
2114 if (save_this_id)
2115 {
2116 // if (oid == 3) g_debug ("Saving Impropers, sa= %d, sb= %d, sc= %d, sd= %d", sa, sb, sc, sd);
2117 tmp_obj_id -> obj = oid;
2118 tmp_obj_id -> type = h;
2119 tmp_obj_id -> oid = i;
2120 if (oid < 5)
2121 {
2122 if (sa > -1) extraz_id[oid][sa] += is_extra;
2123 if (sb > -1) extraz_id[oid][sb] += is_extra;
2124 if (sc > -1) extraz_id[oid][sc] += is_extra;
2125 if (sd > -1) extraz_id[oid][sd] += is_extra;
2126 }
2127 }
2128 }
2129 }
2130 }
2131 }
2132}
2133
2140{
2141 int i, j, k, l;
2142 for (i=0; i<tmp_proj -> nspec-1; i++)
2143 {
2144 if (atoms_id[i] > 0)
2145 {
2146 for (j=i+1; j<tmp_proj -> nspec; j++)
2147 {
2148 if (atoms_id[j] > 0)
2149 {
2150 k = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][i];
2151 l = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][j];
2152 find_object_ijkl (1, 1, 0, i, k, j, l, -1, -1, -1, -1);
2153 find_object_ijkl (1, 1, 0, j, l, i, k, -1, -1, -1, -1);
2154 }
2155 }
2156 }
2157 }
2158 for (i=0; i<tmp_proj -> nspec; i++)
2159 {
2160 if (atoms_id[i] > 0)
2161 {
2162 k = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][i];
2163 find_object_ijkl (1, 1, 0, i, k, i, k, -1, -1, -1, -1);
2164 }
2165 }
2166}
2167
2174{
2175 int i, j, k, l, m, n;
2176 for (i=0; i<tmp_proj -> nspec; i++)
2177 {
2178 if (atoms_id[i] > 0)
2179 {
2180 l = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][i];
2181 for (j=0; j<tmp_proj -> nspec; j++)
2182 {
2183 if (atoms_id[j] > 0)
2184 {
2185 m = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][j];
2186 for (k=0; k<tmp_proj -> nspec; k++)
2187 {
2188 if (atoms_id[k] > 0)
2189 {
2190 n = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][k];
2191 find_object_ijkl (0, 4, 1, i, l, j, m, k, n, -1, -1);
2192 }
2193 }
2194 }
2195 }
2196 }
2197 }
2198}
2199
2208{
2209 int i, j, k, l, m, n, o, p, q;
2210 for (i=0; i<tmp_proj -> nspec; i++)
2211 {
2212 if (atoms_id[i] > 0)
2213 {
2214 m = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][i];
2215 for (j=0; j<tmp_proj -> nspec; j++)
2216 {
2217 if (atoms_id[j] > 0)
2218 {
2219 n = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][j];
2220 for (k=0; k<tmp_proj -> nspec; k++)
2221 {
2222 if (atoms_id[k] > 0)
2223 {
2224 o = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][k];
2225 for (l=0; l<tmp_proj -> nspec; l++)
2226 {
2227 if (atoms_id[l] > 0)
2228 {
2229 p = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][l];
2230 q = (id) ? 1 : 0;
2231 find_object_ijkl (-q, 6+q*2+q*(id-1), 2+id, i, m, j, n, k, o, l, p);
2232 }
2233 }
2234 }
2235 }
2236 }
2237 }
2238 }
2239 }
2240}
2241
2248{
2249 int i, j;
2250 for (i=0; i<tmp_proj -> nspec; i++)
2251 {
2252 if (atoms_id[i] > 0)
2253 {
2254 j = (int)tmp_proj -> chemistry -> chem_prop[CHEM_Z][i];
2255 find_object_ijkl (-1, 10, 5, i, j, -1, -1, -1, -1, -1, -1);
2256 }
2257 }
2258}
2259
2260
2261#ifdef DEBUG
2269void print_all (int oid)
2270{
2271 gchar * prop[7] = {"atom", "bond", "angle", "dihedral", "improper", "inversion", "vdw"};
2272 g_debug ("Field %s found: %d", prop[oid-1], tmp_obj_id -> id+1);
2273 while (tmp_obj_id != NULL)
2274 {
2275 g_debug (" %s N° %d: h= %d, oid= %d", prop[oid-1], tmp_obj_id -> id+1, tmp_obj_id -> type, tmp_obj_id -> oid);
2276 tmp_obj_id = tmp_obj_id -> next;
2277 }
2278}
2279#endif
2280
2289float get_force_field_atom_mass (int sp, int num)
2290{
2291 g_debug ("sp= %d, atoms_id[%d]= %d, num= %d", sp, sp, atoms_id[sp], num);
2292 if (atoms_id[sp] > 0 && num >= 0 && num <= atoms_id[sp])
2293 {
2294 return string_to_double ((gpointer)ff_atoms[atoms_id_list[sp][num]][1]);
2295 }
2296 else
2297 {
2298 return 0.0;
2299 }
2300}
2301
2302#ifdef USE_ATOMS
2303
2305
2314void clean_this_field_data (xmlDoc * doc, xmlTextReaderPtr reader)
2315{
2316 clean_xml_data (doc, reader);
2317 if (filetoread) g_free (filetoread);
2318 filetoread = NULL;
2319 if (ff_objects) g_free (ff_objects);
2320 ff_objects = NULL;
2321 if (ff_dim) g_free (ff_dim);
2322 ff_dim = NULL;
2323 if (ff_key) g_free (ff_key);
2324 ff_key = NULL;
2325 if (ff_info) g_free (ff_info);
2326 ff_info = NULL;
2327 int i;
2328 for (i=0; i<3; i++)
2329 {
2330 if (i < 2)
2331 {
2332 if (ff_angles[i])
2333 {
2334 g_free (ff_angles[i]);
2335 ff_angles[i] = NULL;
2336 }
2337 if (ff_dih[i])
2338 {
2339 g_free (ff_dih[i]);
2340 ff_dih[i] = NULL;
2341 }
2342 }
2343 if (ff_bonds[i])
2344 {
2345 g_free (ff_bonds[i]);
2346 ff_bonds[i] = NULL;
2347 }
2348 }
2349 if (ff_imp)
2350 {
2351 g_free (ff_imp);
2352 ff_imp = NULL;
2353 }
2354 if (ff_inv)
2355 {
2356 g_free (ff_inv);
2357 ff_inv = NULL;
2358 }
2359 if (ff_vdw)
2360 {
2361 g_free (ff_vdw);
2362 ff_vdw = NULL;
2363 }
2364}
2365
2373gchar * open_field_file (int field)
2374{
2375 int i, j;
2376 xmlDoc * doc;
2377 xmlTextReaderPtr reader;
2378 xmlNodePtr racine, f_node;
2379 xmlNodePtr n_node, m_node, o_node;
2381 xmlAttrPtr prop;
2382 const xmlChar fml[7]="ff-xml";
2383 gchar * data_nodes[11]={"atoms", "bonds-h", "bonds-q", "bonds-m", "angles-h", "angles-q",
2384 "dihedrals-c", "dihedrals-ccc", "impropers", "inversions", "non-bonded"};
2385 gchar * data_n[11]={"at", "bd-h", "bd-q", "bd-m", "ang-h", "ang-q",
2386 "dih-c", "dih-ccc", "imp", "inv", "non-bd"};
2387 gchar * str;
2388 filetoread = NULL;
2389 ff_objects = NULL;
2390 ff_dim = NULL;
2391 ff_key = NULL;
2392 ff_info = NULL;
2393 ff_unit = -1;
2394 gchar * force_field_name;
2395 gboolean setinfo;
2396 int odim[10] = {2, 2, 2, 3, 3, 4, 4, 4, 4, 1};
2397 /*
2398 * build an xmlReader for that file
2399 */
2400
2401#ifdef G_OS_WIN32
2402 filetoread = g_strdup_printf ("%s\\force_fields\\%s.ffl", PACKAGE_LIB_DIR, field_ffl[field]);
2403#else
2404 filetoread = g_strdup_printf ("%s/force_fields/%s.ffl", PACKAGE_LIB_DIR, field_ffl[field]);
2405#endif
2406
2407 reader = xmlReaderForFile(filetoread, NULL, 0);
2408 if (reader == NULL)
2409 {
2410 g_warning ("Error reading FF file %s, reader error ?!", filetoread);
2411 return NULL;
2412 }
2413 else
2414 {
2415 doc = xmlParseFile(filetoread);
2416 if (doc == NULL)
2417 {
2418 g_warning ("Error reading FF file %s, xmlParsing error ?!", filetoread);
2419 clean_this_field_data (doc, reader);
2420 return NULL;
2421 }
2422 racine = xmlDocGetRootElement(doc);
2423 if (racine == NULL)
2424 {
2425 g_warning ("Error reading FF file %s, missing XML root node ?!", filetoread);
2426 clean_this_field_data (doc, reader);
2427 return NULL;
2428 }
2429 if (g_strcmp0 ((char *)(racine -> name), (char *)fml) != 0)
2430 {
2431 g_warning ("Error reading FF file %s, missing ff-xml node ?!", filetoread);
2432 clean_this_field_data (doc, reader);
2433 return NULL;
2434 }
2435 // nodes :: field-name, data, atoms, bonds, angles, dihedrals, impropers, inversons, non-bonded, bond-inc ?
2436 f_node = findnode (racine -> children, "force-field");
2437 if (f_node == NULL)
2438 {
2439 g_warning ("Error reading FF file %s, missing force field node ?!", filetoread);
2440 clean_this_field_data (doc, reader);
2441 return NULL;
2442 }
2443 force_field_name = g_strdup_printf ("%s", (gchar *)xmlNodeGetContent(f_node));
2444 f_node = findnode (racine -> children, "units");
2445 if (f_node == NULL)
2446 {
2447 g_warning ("Error reading FF file %s, missing units node ?!", filetoread);
2448 clean_this_field_data (doc, reader);
2449 return NULL;
2450 }
2451 str = g_strdup_printf ("%s", (gchar *)xmlNodeGetContent(f_node));
2452 for (i=0; i<4;i++)
2453 {
2454 if (g_strcmp0 (str, fnames[activef][0][i]) == 0)
2455 {
2456 ff_unit = i;
2457 break;
2458 }
2459 }
2460 if (ff_unit < 0)
2461 {
2462 g_warning ("Error reading FF file %s, units, ff_unit = %d < 0 ?!", filetoread, ff_unit);
2463 clean_this_field_data (doc, reader);
2464 return NULL;
2465 }
2466 f_node = findnode (racine -> children, "ff-data");
2467 if (f_node == NULL)
2468 {
2469 g_warning ("Error reading FF file %s, missing ff-data node ?!", filetoread);
2470 clean_this_field_data (doc, reader);
2471 return NULL;
2472 }
2473 ff_objects = g_malloc0 (11*sizeof*ff_objects);
2474 ff_dim = g_malloc0 (11*sizeof*ff_dim);
2475 //ff_info = g_malloc0 (11*sizeof*ff_key);
2476 ff_key = g_malloc0 (10*sizeof*ff_key);
2477 for (i=0; i<11; i++)
2478 {
2479 m_node = findnode (f_node -> children, data_nodes[i]);
2480 if (m_node == NULL)
2481 {
2482 g_warning ("Error reading FF file %s, ff-data, i= %d, missing node ?!", filetoread, i);
2483 clean_this_field_data (doc, reader);
2484 return NULL;
2485 }
2486 ff_objects[i] = (int)string_to_double ((gpointer)xmlNodeGetContent(m_node));
2487 if (ff_objects[i] < 0)
2488 {
2489 g_warning ("Error reading FF file %s, ff-data, ff_objects[%d] = %d < 0 ?!", filetoread, i, ff_objects[i]);
2490 clean_this_field_data (doc, reader);
2491 return NULL;
2492 }
2493 else if (ff_objects[i])
2494 {
2495 prop = m_node -> properties;
2496 if (prop == NULL)
2497 {
2498 g_warning ("Error reading FF file %s, ff-data, i= %d, missing node prop ?!", filetoread, i);
2499 clean_this_field_data (doc, reader);
2500 return NULL;
2501 }
2502 while (prop)
2503 {
2504 o_node = prop -> children;
2505 if (o_node == NULL)
2506 {
2507 g_warning ("Error reading FF file %s, ff-data, i= %d, missing prop data ?!", filetoread, i);
2508 clean_this_field_data (doc, reader);
2509 return NULL;
2510 }
2511 if (g_strcmp0 ("dim",(char *)prop -> name) == 0)
2512 {
2513 ff_dim[i] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2514 }
2515 /*else if (g_strcmp0 ("info",(char *)prop -> name) == 0)
2516 {
2517 ff_info[i] = (int)string_to_double ((gpointer)xmlNodeGetContent(o_node));
2518 }*/
2519 else if (g_strcmp0 ("pot",(char *)prop -> name) == 0)
2520 {
2521 ff_key[i-1] = (int)string_to_double ((gpointer)xmlNodeGetContent(o_node));
2522 }
2523 prop = prop -> next;
2524 }
2525 }
2526 }
2527 for (i=0; i<11; i++)
2528 {
2529 if (ff_objects[i])
2530 {
2531 f_node = findnode (racine -> children, data_nodes[i]);
2532 if (f_node == NULL)
2533 {
2534 g_warning ("Error reading FF file %s, i= %d, missing node ?!", filetoread, i);
2535 clean_this_field_data (doc, reader);
2536 return NULL;
2537 }
2538 n_node = f_node -> children;
2539 if (n_node == NULL)
2540 {
2541 g_warning ("Error reading FF file %s, i= %d, missing child node ?!", filetoread, i);
2542 clean_this_field_data (doc, reader);
2543 return NULL;
2544 }
2545 if (i == 0)
2546 {
2547 ff_atoms = g_malloc (ff_objects[0]*sizeof*ff_atoms);
2548 for (j=0; j<ff_objects[0]; j++)
2549 {
2550 ff_atoms[j] = g_malloc (ff_dim[0]*sizeof*ff_atoms[j]);
2551 }
2552 }
2553 else if (i < 4)
2554 {
2555 ff_bonds[i-1] = g_malloc0 (sizeof*ff_bonds[i-1]);
2556 ff_data = ff_bonds[i-1];
2557 }
2558 else if (i < 6)
2559 {
2560 ff_angles[i-4] = g_malloc0 (sizeof*ff_angles[i-4]);
2561 ff_data = ff_angles[i-4];
2562 }
2563 else if (i < 8)
2564 {
2565 ff_dih[i-6] = g_malloc0 (sizeof*ff_dih[i-6]);
2566 ff_data = ff_dih[i-6];
2567 }
2568 else if (i == 8)
2569 {
2570 ff_imp = g_malloc0 (sizeof*ff_imp);
2571 ff_data = ff_imp;
2572 }
2573 else if (i == 9)
2574 {
2575 ff_inv = g_malloc0 (sizeof*ff_inv);
2576 ff_data = ff_inv;
2577 }
2578 else if (i == 10)
2579 {
2580 ff_vdw = g_malloc0 (sizeof*ff_vdw);
2581 ff_data = ff_vdw;
2582 }
2583 if (i > 0)
2584 {
2585 ff_data -> atoms_z = g_malloc0 (ff_objects[i]*sizeof*ff_data -> atoms_z);
2586 ff_data -> atoms_id = g_malloc0 (ff_objects[i]*sizeof*ff_data -> atoms_id);
2587 ff_data -> npar = ff_dim[i];
2588 ff_data -> key = ff_key[i-1];
2589 ff_data -> param = g_malloc0 (ff_objects[i]*sizeof*ff_data -> param);
2590 for (j=0; j<ff_objects[i]; j++)
2591 {
2592 ff_data -> atoms_z[j] = g_malloc0 (odim[i-1]*sizeof*ff_data -> atoms_z[j]);
2593 ff_data -> atoms_id[j] = g_malloc0 (odim[i-1]*sizeof*ff_data -> atoms_id[j]);
2594 ff_data -> param[j] = g_malloc0 (ff_dim[i]*sizeof*ff_data -> param[j]);
2595 }
2596 ff_data -> info = g_malloc0 (ff_objects[i]*sizeof*ff_data -> info);
2597 }
2598 setinfo = FALSE;
2599 for (j=0; j<ff_objects[i]; j++)
2600 {
2601 n_node = findnode (n_node, data_n[i]);
2602 if (n_node == NULL)
2603 {
2604 g_warning ("Error reading FF file %s, i= %d, j= %d, missing node ?!", filetoread, i, j);
2605 clean_this_field_data (doc, reader);
2606 return NULL;
2607 }
2608 prop = n_node -> properties;
2609 if (prop == NULL)
2610 {
2611 g_warning ("Error reading FF file %s, i= %d, j= %d, missing prop ?!", filetoread, i, j);
2612 clean_this_field_data (doc, reader);
2613 return NULL;
2614 }
2615 while (prop)
2616 {
2617 o_node = prop -> children;
2618 if (o_node == NULL)
2619 {
2620 g_warning ("Error reading FF file %s, i= %d, j= %d, missing prop node ?!", filetoread, i, j);
2621 clean_this_field_data (doc, reader);
2622 return NULL;
2623 }
2624 switch (i)
2625 {
2626 case 0:
2627 if (g_strcmp0 ("label",(char *)prop -> name) == 0)
2628 {
2629 ff_atoms[j][0] = g_strdup_printf ("%s", (char *)xmlNodeGetContent(o_node));
2630 }
2631 else if (g_strcmp0 ("mass",(char *)prop -> name) == 0)
2632 {
2633 ff_atoms[j][1] = g_strdup_printf ("%s", (char *)xmlNodeGetContent(o_node));
2634 }
2635 else if (g_strcmp0 ("key",(char *)prop -> name) == 0)
2636 {
2637 ff_atoms[j][2] = g_strdup_printf ("%s", (char *)xmlNodeGetContent(o_node));
2638 }
2639 else if (g_strcmp0 ("info",(char *)prop -> name) == 0)
2640 {
2641 ff_atoms[j][3] = g_strdup_printf ("%s", (char *)xmlNodeGetContent(o_node));
2642 }
2643 else
2644 {
2645 g_warning ("Error reading FF file %s, i= %d, j= %d, unexpected node ?!", filetoread, i, j);
2646 clean_this_field_data (doc, reader);
2647 return NULL;
2648 }
2649 break;
2650 default:
2651 if (g_strcmp0 ("a",(char *)prop -> name) == 0)
2652 {
2653 ff_data -> atoms_id[j][0] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2654 }
2655 else if (g_strcmp0 ("b",(char *)prop -> name) == 0)
2656 {
2657 ff_data -> atoms_id[j][1] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2658 }
2659 else if (g_strcmp0 ("c",(char *)prop -> name) == 0)
2660 {
2661 ff_data -> atoms_id[j][2] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2662 }
2663 else if (g_strcmp0 ("d",(char *)prop -> name) == 0)
2664 {
2665 ff_data -> atoms_id[j][3] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2666 }
2667 else if (g_strcmp0 ("z_a",(char *)prop -> name) == 0)
2668 {
2669 ff_data -> atoms_z[j][0] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2670 }
2671 else if (g_strcmp0 ("z_b",(char *)prop -> name) == 0)
2672 {
2673 ff_data -> atoms_z[j][1] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2674 }
2675 else if (g_strcmp0 ("z_c",(char *)prop -> name) == 0)
2676 {
2677 ff_data -> atoms_z[j][2] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2678 }
2679 else if (g_strcmp0 ("z_d",(char *)prop -> name) == 0)
2680 {
2681 ff_data -> atoms_z[j][3] = (int) string_to_double ((gpointer)xmlNodeGetContent(o_node));
2682 }
2683 else if (i > 0 && g_strcmp0 ("info",(char *)prop -> name) == 0)
2684 {
2685 ff_data -> info[j] = g_strdup_printf ("%s", (char *)xmlNodeGetContent(o_node));
2686 setinfo = TRUE;
2687 }
2688 else
2689 {
2690 if (i == 10)
2691 {
2692 // Non-bonded: 12-6: E_i, R_i, E_14, R_14
2693 if (g_strcmp0 ("Ei",(char *)prop -> name) == 0)
2694 {
2695 ff_data -> param[j][0] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2696 }
2697 else if (g_strcmp0 ("Ri",(char *)prop -> name) == 0)
2698 {
2699 ff_data -> param[j][1] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2700 }
2701 else if (g_strcmp0 ("Eii",(char *)prop -> name) == 0)
2702 {
2703 ff_data -> param[j][2] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2704 }
2705 else if (g_strcmp0 ("Rii",(char *)prop -> name) == 0)
2706 {
2707 ff_data -> param[j][3] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2708 }
2709 else if (g_strcmp0 ("A",(char *)prop -> name) == 0)
2710 {
2711 ff_data -> param[j][0] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2712 }
2713 else if (g_strcmp0 ("B",(char *)prop -> name) == 0)
2714 {
2715 ff_data -> param[j][1] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2716 }
2717 else
2718 {
2719 g_warning ("Error reading FF file %s, i= %d, j= %d, unexpected node ?! node name= %s", filetoread, i, j, (char *)prop -> name);
2720 clean_this_field_data (doc, reader);
2721 return NULL;
2722 }
2723 }
2724 else
2725 {
2726 // Bonds: Harm: K, R0
2727 // Bonds: Quartic: K, R_0, K', K''
2728 // Bonds: Morse: D, R_0, Alpha
2729 // Angle: Quartic: K, Theta_0, K', K''
2730 // Dihedral: Cosine: K, Phi_0, n
2731 // Dihedral: Cosine 3: K, Phi_0, K', K''
2732 // Improper: Cosine: K, n, Phi_0 / Harm: K, Phi_0
2733 // Inversion: Harm: K, Phi_0
2734 if (g_strcmp0 ("K",(char *)prop -> name) == 0)
2735 {
2736 ff_data -> param[j][0] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2737 }
2738 else if (g_strcmp0 ("R_zero",(char *)prop -> name) == 0)
2739 {
2740 ff_data -> param[j][1] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2741 }
2742 else if (g_strcmp0 ("Theta_zero",(char *)prop -> name) == 0)
2743 {
2744 ff_data -> param[j][1] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2745 }
2746 else if (g_strcmp0 ("Phi_zero",(char *)prop -> name) == 0)
2747 {
2748 ff_data -> param[j][1] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2749 }
2750 else if (g_strcmp0 ("KK",(char *)prop -> name) == 0)
2751 {
2752 ff_data -> param[j][2] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2753 }
2754 else if (g_strcmp0 ("KKK",(char *)prop -> name) == 0)
2755 {
2756 ff_data -> param[j][3] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2757 }
2758 else if (g_strcmp0 ("Kub",(char *)prop -> name) == 0)
2759 {
2760 ff_data -> param[j][2] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2761 }
2762 else if (g_strcmp0 ("S_zero",(char *)prop -> name) == 0)
2763 {
2764 ff_data -> param[j][3] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2765 }
2766 else if (g_strcmp0 ("n",(char *)prop -> name) == 0)
2767 {
2768 ff_data -> param[j][2] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2769 }
2770 else if (g_strcmp0 ("D",(char *)prop -> name) == 0)
2771 {
2772 ff_data -> param[j][0] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2773 }
2774 else if (g_strcmp0 ("Alpha",(char *)prop -> name) == 0)
2775 {
2776 ff_data -> param[j][2] = string_to_double ((gpointer)xmlNodeGetContent(o_node));
2777 }
2778 else
2779 {
2780 g_warning ("Error reading FF file %s, i= %d, j= %d, unexpected node ?! node name= %s", filetoread, i, j, (char *)prop -> name);
2781 clean_this_field_data (doc, reader);
2782 return NULL;
2783 }
2784 }
2785 }
2786 break;
2787 }
2788 prop = prop -> next;
2789 }
2790 n_node = n_node -> next;
2791 }
2792 if (i > 0 && ! setinfo)
2793 {
2794 g_free (ff_data -> info);
2795 ff_data -> info = NULL;
2796 }
2797 /*if (i==0)
2798 {
2799 for (j=0; j<ff_objects[i]; j++)
2800 {
2801 g_debug ("j= %d, ff_atoms[%d][0]= %s, ff_atoms[%d][1]= %s, ff_atoms[%d][2]= %s, ff_atoms[%d][3]= %s",
2802 j, j, ff_atoms[j][0], j, ff_atoms[j][1], j, ff_atoms[j][2], j, ff_atoms[j][3]);
2803 }
2804 }*/
2805 }
2806 }
2807 xmlFreeDoc(doc);
2808 xmlFreeTextReader(reader);
2809 xmlCleanupParser();
2810 return force_field_name;
2811 }
2812}
2813
2814#endif
2815
2823G_MODULE_EXPORT void setup_this_force_field (int id)
2824{
2825#ifdef USE_ATOMS
2826 // associate_new_pointers_to_field_data (id);
2827 // Atoms
2828 int i;
2829 for (i=0; i<6; i++)
2830 {
2831 if (field_objects_id[i])
2832 {
2834 while (tmp_obj_id -> next)
2835 {
2836 tmp_obj_id = tmp_obj_id -> next;
2837 g_free (tmp_obj_id -> prev);
2838 }
2839 g_free (tmp_obj_id);
2840 field_objects_id[i] = NULL;
2841 }
2842 }
2843 gchar * name = open_field_file (id);
2844 if (g_strcmp0 (name, field_acro[id]) != 0)
2845 {
2846 // Error in xml file ?!
2847 tmp_field -> type = -1;
2848 }
2849 else if (name)
2850 {
2851 int spf = field_find_atoms ();
2852 if (spf < tmp_proj -> nspec)
2853 {
2854 // Some atomic species are not described in this force field
2855 // Take action ?
2856 }
2857
2858 int i;
2859 for (i=0; i<6; i++)
2860 {
2861 if (field_objects_id[i])
2862 {
2864 while (tmp_obj_id -> next)
2865 {
2866 tmp_obj_id = tmp_obj_id -> next;
2867 g_free (tmp_obj_id -> prev);
2868 }
2869 g_free (tmp_obj_id);
2870 field_objects_id[i] = NULL;
2871 }
2872 }
2873
2874 // Bonds
2875 tmp_obj_id = NULL;
2877#ifdef DEBUG
2878 if (tmp_obj_id) print_all (FBDS);
2879#endif
2880
2881 // Angles
2882 tmp_obj_id = NULL;
2884#ifdef DEBUG
2885 if (tmp_obj_id) print_all (FANG);
2886#endif
2887 // Dihedrals
2888 tmp_obj_id = NULL;
2890#ifdef DEBUG
2891 if (tmp_obj_id) print_all (FDIH);
2892#endif
2893 // Impropers
2894 tmp_obj_id = NULL;
2896#ifdef DEBUG
2897 if (tmp_obj_id) print_all (FIMP);
2898#endif
2899 // Inversions
2900 tmp_obj_id = NULL;
2902#ifdef DEBUG
2903 if (tmp_obj_id) print_all (FINV);
2904#endif
2905 // Vdw
2906 tmp_obj_id = NULL;
2907 field_find_vdw ();
2908#ifdef DEBUG
2909 if (tmp_obj_id) print_all (FNBD);
2910#endif
2911 }
2912#else
2913 int i;
2914 gchar * str;
2915 //FILE * hp = fopen ("force_fields.h", "w");
2916 for (i=0; i<N_FIELDS; i++)
2917 {
2918 g_debug ("\n\nField id= %d, name= %s", i, field_keyw[i]);
2919 associate_pointers_to_field_data (i);
2920 is_99 = (i==CHARMM22M) ? TRUE : FALSE;
2921 str = g_strdup_printf ("%s/force_fields/%s.ffl", PACKAGE_LIB_DIR, field_ffl[i]);
2922 fp = fopen (str, "w");
2923 fprintf (fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
2924 fprintf (fp, "<!-- Force Field Library XML file -->\n");
2925 fprintf (fp, "<ff-xml>\n");
2926 fprintf (fp, " <force-field>%s</force-field>\n", field_acro[i]);
2927 fprintf (fp, " <!-- data adapted from the file: %s -->\n", ffo_file[i]);
2928 fprintf (fp, " <units>k-calories per mol</units>\n");
2929 g_free (str);
2931 print_atom_table (i);
2932 print_bond_table (i, 3);
2933 print_angle_table (i, 6);
2934 print_dihedral_table (i, 8);
2935
2936 print_improper_table (i, 11);
2937 print_inversion_table (i, 10);
2938 print_vdw_table (i, 12);
2939 //print_increment_table (i, 13)
2940 fprintf (fp, "</ff-xml>\n");
2941 fclose (fp);
2942 }
2943 //fclose (hp);
2944
2945#endif
2946}
integer(kind=c_int) function chemistry()
Definition chemistry.F90:22
gchar * param[2]
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]
int bonds[NUM_STYLES][2]
float val
Definition dlp_init.c:117
field_data * ff_data
project * tmp_proj
Definition dlp_field.c:953
gchar * fnames[2][16][21]
Definition dlp_field.c:218
classical_field * tmp_field
Definition dlp_field.c:951
Variable declarations for the creation of the DL_POLY input file(s)
#define CHARMM35E
Definition dlp_field.h:126
#define CHARMMSI
Definition dlp_field.h:133
#define CHARMM36N
Definition dlp_field.h:130
#define COMPASS
Definition dlp_field.h:138
#define CHARMM36G
Definition dlp_field.h:128
#define CFF91
Definition dlp_field.h:136
#define AMBER94
Definition dlp_field.h:120
#define CHARMM22P
Definition dlp_field.h:124
#define CVFF
Definition dlp_field.h:134
#define OPLSAAR
Definition dlp_field.h:140
#define CVFF_AUG
Definition dlp_field.h:135
#define AMBER96
Definition dlp_field.h:121
#define AMBER99
Definition dlp_field.h:123
#define CHARMM36P
Definition dlp_field.h:131
#define PCFF
Definition dlp_field.h:137
#define CHARMM22M
Definition dlp_field.h:125
#define OPLSAAP
Definition dlp_field.h:139
#define CHARMM36M
Definition dlp_field.h:132
#define AMBER98
Definition dlp_field.h:122
#define CHARMM36C
Definition dlp_field.h:127
#define CHARMM36L
Definition dlp_field.h:129
char *** field_equi[2]
void set_data(int pid, int obj, int oid, int faid)
save retrieved force field data
void field_find_dihedrals(int id)
retrieve available dihedral parameters in force field database
field_data * ff_angles[2]
int get_z(int faid)
get field atom Z
gboolean is_a_match(int *data, int num, int val[4])
is this a match ?
int get_angle(int faid, int aid)
retrieve all angle parameter(s) for this field atom
int get_bond(int faid, int bid)
retrieve all bonding parameter(s) for this field atom
char *** field_inversions
void print_improper_table(int fid, int inum)
print improper(s) table to file
f_bond * the_bonds[2]
int get_fkey(int fid, int prop, int col)
retrieve key for property in force field database
gchar * find_atom_key(int fid, int prop, char *keyw)
retrieve property key in force field database for atom
void print_this_bond(int eid, int h, int fid, int inum, char *at_a, char *at_b, char **the_bond)
print this bond to file
xmlNodePtr findnode(xmlNodePtr startnode, char *nname)
find XML node
f_bond * tmpbd
void print_dihedral_table(int fid, int inum)
print dihedral(s) table to file
void find_object_ijkl(int hid, int foid, int oid, int sa, int za, int sb, int zb, int sc, int zc, int sd, int zd)
retrieve parameter from force field database
char *** field_bonds[3]
float get_force_field_atom_mass(int sp, int num)
get force field atomic mass
int get_pdim(int fid, int prop, int col)
retrieve number of parameters for property in force field database
gchar * table_name[11]
field_data * ff_vdw
field_data * ff_dih[2]
gchar * prop_name[11]
gchar * open_field_file(int field)
open force field XML file
#define FNBD
void field_find_angles()
retrieve available angle parameters in force field database
char *** field_impropers
void print_atom_table(int fid)
print force field atom data to file
gboolean is_99
G_MODULE_EXPORT void setup_this_force_field(int id)
setup force field parameters
char *** field_vdw
int * ff_key
int find_atom_id(int print, char *keyw)
find atom id in force field database
void clean_this_field_data(xmlDoc *doc, xmlTextReaderPtr reader)
free force field XML file data
int ffdim[14][2]
#define FIMP
int * ff_objects
field_data * ff_imp
#define FDIH
void print_this_angle(int eid, int h, int fid, int inum, int ub, char *at_a, char *at_b, char *at_c, char **the_angle)
print this angle to file
int ** atoms_id_list
void print_inversion_table(int fid, int inum)
print inversion(s) table to file
#define FINV
int get_torsion(int faid, int tid, int a, int b)
retrieve all torsion parameter(s) for this field atom
field_object_match ** all_data[10]
f_angl * tmpan
gchar * ffo_file[21]
void field_has_element(int aid)
retrieve force field parameters for this atom
char * field_ffl[N_FIELDS]
char * field_acro[N_FIELDS]
int * ff_info
int * ff_dim
FILE * fp
int ffpot[N_FIELDS][10]
int * field_dim
field_object_match * field_objects_id[6]
char *** field_atoms
char * field_name[N_FIELDS]
gboolean not_done(int eid, int a, int b)
was this case already considered ?
int ** extraz_id
int * atoms_id
void field_find_vdw()
retrieve available VdW parameters in force field database
int get_improper(int faid, int a, int b)
retrieve all improper parameter(s) for this field atom
int clean_xml_data(xmlDoc *doc, xmlTextReaderPtr reader)
free XML data
Definition w_library.c:322
char * field_keyw[N_FIELDS]
int * field_objects
void print_object_dim_and_key_tables(int fid)
print tables dimensions and keys to file
void print_angle_table(int fid, int inum)
print angle(s) table to file
field_object_match * om_tmp
void field_find_bonds()
retrieve available bond parameters in force field database
int find_atom_z(char *keyw)
find atom Z
field_object_match * tmp_obj_id
f_angl * the_angles[2]
void print_bond_table(int fid, int inum)
print force field bond table to file
#define FBDS
int get_atoms(int z)
retrieve all field atom(s) with matching Z
int get_apex(int faid, int aid)
retrieve all angle apex parameter(s) for this field atom
int is_extra
char *** field_angles[2]
#define N_FIELDS
int field_find_atoms()
retrieve matching atom from force field data base
field_data * ff_bonds[3]
gboolean not_done_an(int eid, int a, int b, int c)
was this case already considered ?
char *** field_dihedrals[2]
int get_vdw(int faid)
retrieve all VdW parameter(s) for this field atom
char *** ff_atoms
field_data * ff_inv
int ff_unit
#define FANG
gchar * filetoread
void print_vdw_table(int fid, int inum)
print VdW table to file
Variable declarations for the creation of the force field database.
int charmm36_cgenff_objects[14]
int CFF91_objects[14]
char * charmm36_prot_impropers[35][8]
int OPLSAAR_dim[14]
char * amber99_vdw[42][4]
char * charmm_silicates_dihedrals[34][8]
char * CVFF_aug_atoms[172][5]
char * Compass_angles[94][8]
char * charmm_silicates_vdw[13][6]
int charmm35_ethers_dim[14]
char * amber98_atoms[2][4]
char * charmm36m_prot_angles[364][8]
char * amber99_atoms[2][5]
char * CVFF_torsions_auto[295][8]
int charmm36m_prot_objects[14]
char * charmm36_prot_bonds[132][5]
char * PCFF_inversions[83][7]
char * OPLSAAR_dihedrals[2482][7]
char * PCFF_vdw[94][4]
char * charmm22_prot_vdw[47][6]
char * Compass_bonds[54][7]
char * amber94_vdw[34][4]
char * charmm36_prot_vdw[53][6]
int Compass_objects[14]
char * CFF91_inversions[70][7]
char * charmm36_carb_vdw[57][6]
char * OPLSAAR_bonds[242][5]
char * charmm22_prot_metals_bonds[139][5]
char * amber99_bonds[116][5]
int charmm36_na_objects[14]
char * amber94_impropers[31][8]
char * CVFF_aug_angles_auto[640][6]
int amber94_objects[14]
char * charmm36_cgenff_vdw[156][6]
char * Compass_torsions[95][11]
char * charmm36_na_bonds[89][5]
char * charmm36_prot_angles[364][8]
int amber98_dim[14]
int charmm36_na_dim[14]
char * charmm36_na_vdw[42][6]
char * charmm35_ethers_bonds[22][5]
char * CVFF_aug_torsions_auto[342][8]
char * CVFF_impropers[41][8]
char * amber98_bonds[83][5]
char * amber99_equi[2][15]
char * amber98_vdw[35][4]
char * CVFF_aug_equivalence_auto[162][11]
char * charmm36_na_dihedrals[502][8]
int charmm36_prot_dim[14]
char * CFF91_atoms[93][5]
char * charmm36_cgenff_bonds[506][5]
char * charmm36_lipid_atoms[29][5]
int charmm35_ethers_objects[14]
char * PCFF_angles[302][8]
char * charmm35_ethers_atoms[13][5]
int amber96_objects[14]
char * charmm22_prot_dihedrals[445][8]
char * CVFF_aug_impropers[41][8]
char * charmm36_lipid_dihedrals[180][8]
char * charmm36_prot_dihedrals[705][8]
char * charmm36m_prot_dihedrals[706][8]
int CVFF_aug_dim[14]
char * charmm_silicates_bonds[14][5]
char * OPLSAAR_vdw[145][7]
char * charmm36_cgenff_dihedrals[3937][8]
char * charmm36_carb_atoms[59][5]
char * PCFF_angles_auto[329][6]
char * CVFF_equivalence[129][7]
char * amber96_atoms[2][4]
char * CVFF_aug_vdw[86][4]
int charmm36m_prot_dim[14]
char * CVFF_angles_auto[563][6]
char * CFF91_equivalence_auto[97][11]
char * charmm35_ethers_vdw[13][6]
char * charmm36_carb_dihedrals[1354][8]
char * charmm35_ethers_angles[55][8]
int charmm36_carb_dim[14]
int charmm36_prot_objects[14]
char * charmm22_prot_metals_impropers[43][8]
char * charmm22_prot_metals_atoms[98][5]
char * charmm22_prot_metals_dihedrals[452][8]
char * CVFF_equivalence_auto[123][11]
int charmm22_prot_dim[14]
char * PCFF_equivalence[134][7]
char * charmm36_lipid_vdw[29][6]
char * OPLSAAR_impropers[131][7]
char * Compass_equivalence[46][7]
int amber99_dim[14]
char * PCFF_equivalence_auto[108][11]
int amber98_objects[14]
char * charmm36_cgenff_angles[1561][8]
char * OPLSAAM_atoms[78][4]
int CFF91_dim[14]
char * CVFF_aug_equivalence[168][7]
char * CFF91_angles_auto[330][6]
int amber99_objects[14]
char * CFF91_equivalence[95][7]
char * PCFF_torsions[492][11]
char * charmm36_lipid_angles[131][8]
char * OPLSAAR_angles[593][5]
char * amber96_vdw[35][4]
char * CVFF_aug_bonds_auto[798][5]
int OPLSAAM_dim[14]
char * charmm36_prot_atoms[53][5]
int CVFF_aug_objects[14]
char * charmm36m_prot_impropers[35][8]
char * CVFF_bonds_auto[776][5]
char * charmm_silicates_atoms[13][5]
char * amber94_atoms[2][4]
char * CFF91_torsions_auto[216][8]
char * charmm22_prot_angles[324][8]
char * CFF91_angles[155][8]
char * charmm22_prot_atoms[47][5]
char * amber96_equi[2][15]
char * amber99_angles[281][6]
char * PCFF_torsions_auto[216][8]
char * CFF91_bonds_auto[667][5]
char * amber99_impropers[38][8]
int charmm22_prot_metals_dim[14]
char * OPLSAAM_dihedrals[1446][7]
char * CFF91_bonds[58][7]
char * CVFF_atoms[133][5]
char * charmm36_cgenff_atoms[163][5]
int amber96_dim[14]
char * amber98_equi[2][15]
char * amber94_dihedrals[81][9]
char * amber94_equi[2][15]
char * CVFF_aug_morse_bonds[752][6]
int amber94_dim[14]
int Compass_dim[14]
char * amber98_dihedrals[83][9]
int PCFF_objects[14]
int OPLSAAM_objects[14]
char * charmm36_carb_impropers[14][8]
char * CFF91_vdw[40][4]
char * amber96_bonds[83][5]
int CVFF_objects[14]
char * CFF91_torsions[294][11]
int PCFF_dim[14]
char * OPLSAAM_vdw[78][7]
int CVFF_dim[14]
char * amber94_bonds[83][5]
char * charmm35_ethers_dihedrals[106][8]
int charmm22_prot_metals_objects[14]
char * CVFF_morse_bonds[775][6]
char * charmm36_carb_angles[438][8]
char * amber99_dihedrals[164][9]
char * charmm36_na_atoms[42][5]
int charmm36_lipid_objects[14]
char * charmm36m_prot_vdw[53][6]
char * charmm36_lipid_bonds[50][5]
char * charmm36m_prot_atoms[53][5]
int charmm_silicates_objects[14]
char * Compass_vdw[46][4]
char * charmm22_prot_impropers[34][8]
char * charmm36_lipid_impropers[4][8]
char * OPLSAAR_atoms[145][4]
char * OPLSAAM_bonds[159][5]
char * charmm36_cgenff_impropers[125][8]
char * amber96_dihedrals[81][9]
char * charmm_silicates_angles[27][8]
char * charmm36_na_impropers[15][8]
char * amber96_impropers[31][8]
char * PCFF_atoms[133][5]
char * charmm36m_prot_bonds[132][5]
int charmm36_carb_objects[14]
char * charmm22_prot_metals_angles[345][8]
char * charmm22_prot_metals_vdw[98][6]
char * Compass_atoms[45][5]
char * amber98_impropers[31][8]
char * amber98_angles[191][6]
int OPLSAAR_objects[14]
char * OPLSAAM_impropers[105][7]
int charmm36_cgenff_dim[14]
int charmm22_prot_objects[14]
char * OPLSAAM_angles[437][5]
int charmm_silicates_dim[14]
char * amber96_angles[191][6]
char * Compass_inversions[22][7]
int charmm36_lipid_dim[14]
char * PCFF_bonds_auto[627][5]
char * PCFF_bonds[126][7]
char * charmm22_prot_bonds[122][5]
char * charmm36_na_angles[226][8]
char * amber94_angles[191][6]
char * charmm36_carb_bonds[153][5]
char * CVFF_vdw[45][4]
int ** allocdint(int xal, int yal)
allocate an int ** pointer
Definition global.c:330
gchar * PACKAGE_LIB_DIR
Definition global.c:78
int activef
Definition global.c:161
int * allocint(int val)
allocate an int * pointer
Definition global.c:314
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...
element_data periodic_table_info[]
Definition w_library.c:71
#define CHEM_Z
Definition global.h:297
int objects[3]
Definition selection.c:212
gchar * exact_name(gchar *name)
short cut to print string without spaces
Definition interface.c:370
Messaging function declarations.
double z
Definition ogl_draw.c:57
f_angl * prev
f_angl * next
float v[2]
f_bond * prev
float v[2]
f_bond * next
int b
Definition tab-1.c:95
int c
Definition tab-1.c:95
int a
Definition tab-1.c:95
GtkWidget * lab
Definition workspace.c:73