1 /********************************
2 *
3 * Header file for msi2lmp conversion program.
4 *
5 * This is the header file for the third version of a program
6 * that generates a LAMMPS data file based on the information
7 * in an MSI car file (atom coordinates) and mdf file (molecular
8 * topology). A key part of the program looks up forcefield parameters
9 * from an MSI frc file.
10 *
11 * The first version was written by Steve Lustig at Dupont, but
12 * required using Discover to derive internal coordinates and
13 * forcefield parameters
14 *
15 * The second version was written by Michael Peachey while an
16 * intern in the Cray Chemistry Applications Group managed
17 * by John Carpenter. This version derived internal coordinates
18 * from the mdf file and looked up parameters in the frc file
19 * thus eliminating the need for Discover.
20 *
21 * The third version was written by John Carpenter to optimize
22 * the performance of the program for large molecular systems
23 * (the original code for derving atom numbers was quadratic in time)
24 * and to make the program fully dynamic. The second version used
25 * fixed dimension arrays for the internal coordinates.
26 *
27 * The third version was revised in Fall 2011 by
28 * Stephanie Teich-McGoldrick to add support non-orthogonal cells.
29 *
30 * The next revision was started in Summer/Fall 2013 by
31 * Axel Kohlmeyer to improve portability to Windows compilers,
32 * clean up command line parsing and improve compatibility with
33 * the then current LAMMPS versions. This revision removes
34 * compatibility with the obsolete LAMMPS version written in Fortran 90.
35 */
36 
37 #include <stdio.h>              /* IWYU pragma: export */
38 
39 #define MSI2LMP_VERSION "v3.9.9 / 05 Nov 2018"
40 
41 #define PI_180  0.01745329251994329576
42 
43 #define MAX_LINE_LENGTH  256
44 #define MAX_CONNECTIONS    8
45 #define MAX_STRING        64
46 #define MAX_NAME          16
47 
48 #define WHITESPACE " \t\r\n\f"
49 
50 #define MAX_ATOM_TYPES         100
51 #define MAX_BOND_TYPES         200
52 #define MAX_ANGLE_TYPES        300
53 #define MAX_DIHEDRAL_TYPES     400
54 #define MAX_OOP_TYPES          400
55 #define MAX_ANGLEANGLE_TYPES   400
56 #define MAX_TYPES            12000
57 
58 #define FF_TYPE_COMMON       1<<0
59 #define FF_TYPE_CLASS1       1<<1
60 #define FF_TYPE_CLASS2       1<<2
61 #define FF_TYPE_OPLSAA       1<<3
62 
63 struct ResidueList {
64   int start;
65   int end;
66   char name[MAX_NAME];
67 };
68 
69 struct MoleculeList {
70   int start;
71   int end;
72   int no_residues;
73   struct ResidueList *residue;
74 };
75 
76 /* Internal coodinate Lists */
77 
78 struct BondList {
79   int type;
80   int members[2];
81 };
82 
83 struct AngleList {
84   int type;
85   int members[3];
86 };
87 
88 struct DihedralList {
89   int type;
90   int members[4];
91 };
92 
93 struct OOPList {
94   int type;
95   int members[4];
96 };
97 
98 struct AngleAngleList {
99   int type;
100   int members[4];
101 };
102 
103 /* Internal coodinate Types Lists */
104 
105 
106 struct AtomTypeList
107 {
108   char potential[5];
109   double mass;
110   double params[2];
111   int no_connect;
112 };
113 
114 struct BondTypeList {
115   int types[2];
116   double params[4];
117 };
118 
119 struct AngleTypeList {
120   int types[3];
121   double params[4];
122   double bondangle_cross_term[4];
123   double bondbond_cross_term[3];
124 };
125 
126 struct DihedralTypeList {
127   int types[4];
128   double params[6];
129   double endbonddihedral_cross_term[8];
130   double midbonddihedral_cross_term[4];
131   double angledihedral_cross_term[8];
132   double angleangledihedral_cross_term[3];
133   double bond13_cross_term[3];
134 };
135 
136 struct OOPTypeList {
137   int types[4];
138   double params[3];
139   double angleangle_params[6];
140 };
141 
142 struct AngleAngleTypeList {
143   int types[4];
144   double params[6];
145 };
146 
147 /* ---------------------------------------------- */
148 
149 struct Atom {
150   int   molecule;        /* molecule id */
151   int   no;              /* atom id */
152   char  name[MAX_NAME];  /* atom name */
153   double x[3];           /* position vector */
154   int   image[3];        /* image flag */
155   char  potential[6];    /* atom potential type */
156   char  element[4];      /* atom element */
157   double q;              /* charge */
158   char  residue_string[MAX_NAME]; /* residue string */
159   int  no_connect;        /* number of connections to atom */
160   char connections[MAX_CONNECTIONS][MAX_STRING];  /* long form, connection name*/
161   double bond_order[MAX_CONNECTIONS];
162   int conn_no[MAX_CONNECTIONS];         /* Atom number to which atom is connected */
163   int type;
164 };
165 
166 extern char  *rootname;
167 extern char  *FrcFileName;
168 extern double pbc[6];        /* A, B, C, alpha, beta, gamma */
169 extern double box[3][3];     /* hi/lo for x/y/z and xy, xz, yz for triclinic */
170 extern double shift[3];      /* shift vector for all coordinates and box positions */
171 extern int    periodic;      /* 0= nonperiodic 1= 3-D periodic */
172 extern int    TriclinicFlag; /* 0= Orthogonal  1= Triclinic */
173 extern int    forcefield;    /* BitMask: the value FF_TYPE_COMMON is set for common components of the options below,
174                               * FF_TYPE_CLASS1 = ClassI,  FF_TYPE_CLASS2 = ClassII, FF_TYPE_OPLSAA = OPLS-AA*/
175 extern int    ljtypeflag;    /* how LJ parameters are stored: 0 = A-B, 1 = r-eps */
176 extern int    centerflag;    /* 1= center box  0= keep box */
177 extern int    hintflag;      /* 1= print style hint comments  0= no hints */
178 extern int    pflag;         /* print level: 0, 1, 2, 3 */
179 extern int    iflag;         /* 0 stop at errors   1 = ignore errors */
180 extern int    *no_atoms;
181 extern int    no_molecules;
182 extern int    replicate[3];
183 extern int    total_no_atoms;
184 extern int    total_no_bonds;
185 extern int    total_no_angles;
186 extern int    total_no_dihedrals;
187 extern int    total_no_angle_angles;
188 extern int    total_no_oops;
189 extern int    no_atom_types;
190 extern int    no_bond_types;
191 extern int    no_angle_types;
192 extern int    no_dihedral_types;
193 extern int    no_oop_types;
194 extern int    no_angleangle_types;
195 extern FILE   *CarF;
196 extern FILE   *FrcF;
197 extern FILE   *PrmF;
198 extern FILE   *MdfF;
199 extern FILE   *RptF;
200 extern struct Atom *atoms;
201 extern struct MoleculeList *molecule;
202 extern struct BondList *bonds;
203 extern struct AngleList *angles;
204 extern struct DihedralList *dihedrals;
205 extern struct OOPList *oops;
206 extern struct AngleAngleList *angleangles;
207 extern struct AtomTypeList *atomtypes;
208 extern struct BondTypeList *bondtypes;
209 extern struct AngleTypeList *angletypes;
210 extern struct DihedralTypeList *dihedraltypes;
211 extern struct OOPTypeList *ooptypes;
212 extern struct AngleAngleTypeList *angleangletypes;
213 
214 extern void FrcMenu();
215 extern void ReadCarFile();
216 extern void ReadMdfFile();
217 extern void ReadFrcFile();
218 extern void ClearFrcData();
219 extern void MakeLists();
220 extern void GetParameters();
221 extern void CheckLists();
222 extern void WriteDataFile(char *);
223 
224 extern void set_box(double box[3][3], double *h, double *h_inv);
225 extern void lamda2x(double *lamda, double *x, double *h, double *boxlo);
226 extern void x2lamda(double *x, double *lamda, double *h_inv, double *boxlo);
227 
228 extern void condexit(int);
229